lookup.
Used to find date of holidays that fall on different days of the year obviously.
Example US Thanksgiving is the 4th Thursday of November
Dim search As notesdatetime
Sub Initialize
h_year = 2000 ' year of desired date
h_dow = 5 ' represents the day of week.. sunday being 1 saturday being 7
h_mon = "November" ' This is the month that you want the holiday listed.
h_which = 4 ' numeric value of how many of the day of week. This example
' will return the 4th thursday in november [Thanksgiving US]
' For last week.. use 10
Call find_holiday(h_year,h_dow,h_mon,h_which)
End Sub
Function find_holiday(h_year,h_dow,h_mon,h_which)
Dim dayofweek As Variant
Set search = New notesdatetime(h_mon + " 1, " + Str(h_year))
dayofweek = Evaluate("@WeekDay([" + search.localtime + "])")
s_month = Evaluate("@Month([" + search.localtime + "])")
s_dow = dayofweek(0)
If(s_dow > h_dow) Then
Call search.AdjustDay(7 - (s_dow - h_dow))
Else
Call search.AdjustDay(h_dow - s_dow)
End If
week_number = 1
While(week_number <> h_which)
Call search.AdjustDay(7)
week_number = week_number + 1
c_month = Evaluate("@Month([" + search.localtime + "])")
If(c_month(0) <> s_month(0)) Then ' went beyond end of month
If(c_which <> 10) Then
Msgbox " Error: Number of weeks exceeded month limit"
Exit Function
Else
Call.search.Adjustday(-7)
Goto break_out
End If
End If
Wend
break_out:
End Function
This was first published in November 2000