Public Function isHoliday(ByVal dtmDate As Date) As Boolean
Dim intYear As Integer
Dim intMonth As Integer
Dim intDay As Integer
Dim intWeekDay As Integer
intYear = Year(dtmDate)
intMonth = Month(dtmDate)
intDay = Day(dtmDate)
intWeekDay = Weekday(dtmDate)
'If you do not care if a holiday falls on a weekend
'If intWeekDay > 1 And intWeekDay < 7 Then exit Function
'New Years Day
If DatePart("y", dtmDate) = 1 Then
isHoliday = True
Exit Function
End If
'ML King 3rd Monday of Jan
If DayOfNthWeek(intYear, 1, 3, vbMonday) = dtmDate Then
isHoliday = True
Exit Function
End If
'Presidents Day 3rd Monday of Feb
If DayOfNthWeek(intYear, 2, 3, vbMonday) = dtmDate Then
isHoliday = True
Exit Function
End If
'Memorial Day Last Monday of May
If LastMondayInMonth(intYear, 5) = dtmDate Then
isHoliday = True
Exit Function
End If
'Independance Day
If intMonth = 7 And intDay = 4 Then
isHoliday = True
Exit Function
End If
'Labor Day 1st Monday of Sep
If DayOfNthWeek(intYear, 9, 1, vbMonday) = dtmDate Then
isHoliday = True
Exit Function
End If
'Columbus Day 2nd Monday of Oct
If DayOfNthWeek(intYear, 10, 2, vbMonday) = dtmDate Then
isHoliday = True
Exit Function
End If
' Veteranss Day
' Although originally scheduled for celebration on November 11,
' starting in 1971 Veterans Day was moved to the fourth Monday of October.
' In 1978 it was moved back to its original celebration on November 11.
If intMonth = 11 And intDay = 11 Then
isHoliday = True
Exit Function
End If
'Thanksgiving Day 4th Thursday of Nov
If DayOfNthWeek(intYear, 11, 4, vbThursday) = dtmDate Then
isHoliday = True
Exit Function
End If
'CHRISTMAS
If intMonth = 12 And intDay = 25 Then isHoliday = True
End Function
Public Function DayOfNthWeek(intYear As Integer, intMonth As Integer, N As Integer, vbDayOfWeek As Integer) As Date
'Thanksgiving is the 4th thursday in November(11)
'dayOfNthWeek(theYear,11,4,vbThursday)
DayOfNthWeek = DateSerial(intYear, intMonth, (8 - Weekday(DateSerial(intYear, intMonth, 1), _
(vbDayOfWeek + 1) Mod 8)) + ((N - 1) * 7))
End Function
Function LastMondayInMonth(intYear As Integer, intMonth As Long) As Date
'Used for memorial day
Dim LastDay As Date
'define last day of the month of interest:
LastDay = DateSerial(intYear, intMonth + 1, 0)
'use to get last monday:
LastMondayInMonth = LastDay - Weekday(LastDay, vbMonday) + 1
End Function