Holiday Finder

Use this script to get a DateTime object representing the holiday you wish to
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))
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
Goto break_out
End If
End If
End Function

This was first published in November 2000

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.