Display Value dependant on week number

Merry Christmas All,

I have a DB which is used to schedule weekly Admin work. On of the tasks is to perform Cluster Analysis on 1 of 18 Clusters in our environment and at the moment the form contains a simple pick list. The problem is that it allows the person to pick and server and some servers could be done twice and some not at all.

Is there a way I can put a forumla in the field to default to the next Cluster pair. This can be based on the week number of the Cluster last completed.

Any suggestions / code examples examples would be very welcome.

Happy Holidays all,

TB

Subject: Code is attached …

Hi Tone ,

The code is attached below…SomeDate is the date field …

Week 1 for any year, is the first week in Jan that has 4 January days.

Treat this as a Christmas gift :)) …Merry Christmas !!!

Jan1st := @Date(@Year(SomeDate); 1; 1);

REM {Jan 1st same same year (not necessarily part of week 1)};

Adjust := 3 - @Modulo((@Weekday(Jan1st) + 1); 7);

REM {Number of days to Monday week 1};

MondayW1 := @Adjust(Jan1st; 0; 0; Adjust;0; 0; 0);

REM {Date for Monday week 1};

WeekNumber := 1 + @Integer(((SomeDate - MondayW1)/86400)/7);

@If(@IsError(WeekNumber);“”;WeekNumber)

Regards

Siddhartha

Subject: This would also help : Lotus Script

Hi Tone , this would also work …for LOTUS SCRIPT


Msgbox Format(Today, “ww”), 0+64+0+0, “Week number of Today”

Subject: RE: This would also help : Lotus Script

Unfortunately, it appears that the code that Lotus provides for formatting a date to display week number is not the same code that Lotus uses for calendar purposes.

I tested by putting the following code into a button:

Sub Click(Source As Button)

Const WEEK_EVAL_FORMULA = |Jan1st := @Date(@Year(SomeDate); 1; 1); REM {Jan 1st same same year (not necessarily part of week 1)}; 

Adjust := 3 - @Modulo((@Weekday(Jan1st) + 1); 7); REM {Number of days to Monday week 1};

MondayW1 := @Adjust(Jan1st; 0; 0; Adjust;0; 0; 0); REM {Date for Monday week 1}; 

WeekNumber := 1 + @Integer(((SomeDate - MondayW1)/86400)/7);

WeekNumber|



Dim uiws As New NotesUIWorkspace

Dim uidoc As Notesuidocument

Dim doc As NotesDocument

Dim i As Integer

Dim fileHandle As Integer

Dim varTemp As Variant



fileHandle = Freefile()

Open "c:\temp\WeekdayNumber.txt" For Output As fileHandle



Set uidoc = uiws.CurrentDocument

Set doc = uidoc.Document



Print #fileHandle, "Year", "Formula", "Script"



For i = 1970 To 2008

	doc.ReplaceItemValue "SomeDate", Dateserial(i, Month(Today), Day(Today))

	varTemp = Evaluate(WEEK_EVAL_FORMULA, doc)

	Print #fileHandle, i, varTemp(0), Format(doc.SomeDate(0), "ww")

Next



Close fileHandle

End Sub

and when I ran the code (on Sept. 30, 2007), the output that was contained was:

Year Formula Script

1970 40 40

1971 39 40

1972 39 40

1973 39 40

1974 40 40

1975 40 40

1976 40 40

1977 39 40

1978 39 39

1979 39 40

1980 40 40

1981 40 40

1982 39 40

1983 39 40

1984 39 40

1985 40 40

1986 40 40

1987 40 40

1988 39 40

1989 39 39

1990 39 40

1991 40 40

1992 40 40

1993 39 40

1994 39 40

1995 39 39

1996 40 40

1997 40 40

1998 40 40

1999 39 40

2000 39 40

2001 39 40

2002 40 40

2003 40 40

2004 40 40

2005 39 40

2006 39 39

2007 39 40

2008 40 40

Note the discrepancies between one method of calculating and the other. Also note that if you look into the Notes calendar, the week number displayed at the bottom of the weekly view corresponds to the value obtained by formula and not by script.

Bottom line: Do not trust Format(date, “ww”) to return the correct week number.

Subject: Display Value dependant on week number

Suggest you have an editable date field that holds the static value of the first Sunday of the year. This field can be hidden so users do not edit it.

name = Firstday value = [01/01/2006]

Then have a computed number field that makes use of @businessdays function

name = WhatWeek

value =@Integer(@BusinessDays(firstday;@Today)/7)

Now extend this formula to divide by 18 and use the remainder as the cluster to be administered

name = WhatWeek

value = @Modulo(@Integer(@BusinessDays(firstday;@Today)/7);18)

UPDATE

Add 1 to the value otherwise your possible values are 0 - 17

name = WhatWeek

value = @Modulo(@Integer(@BusinessDays(firstday;@Today)/7);18)+1

HTH