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.
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.