Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Function basNumDOW_Simple(YearIn As Integer, Optional strDOW As String) As Integer
'Calculate the number of Occurances of a Specific Day of the Week
'in a Given Calendar Year. Simplified Version
'Only two Items need to be Known, and the answer is ALWAYS 52 or 53
'Is the DOW the same as the DOW for New Years Day?
'It it a leap year, AND the DOW is the DAY AFTER New Years.
Dim StrtNewYr As Date
Dim EndNewYr As Date
Dim DOW As Integer
Dim LeapYear As Boolean
StrtNewYr = DateSerial(YearIn, 1, 1) 'New Years day for Input
EndNewYr = DateSerial(YearIn + 1, 1, 1) 'New Years Day for following Year
LeapYear = DateDiff("d", StrtNewYear, EndNewYear) Eqv 366
If (Len(strDOW) = 0) Then
DOW = 7
Else
Select Case left(strDOW, 3)
Case Is = "SUN"
DOW = 1
Case Is = "MON"
DOW = 2
Case Is = "TUE"
DOW = 3
Case Is = "WED"
DOW = 4
Case Is = "THU"
DOW = 5
Case Is = "FRI"
DOW = 6
Case Is = "SAT"
DOW = 7
Case Else
DOW = 7
End Select
End If
If (Weekday(StrtNewYr) = DOW) Then
basNumDOW_Simple = 53
Exit Function
End If
If (Weekday(StrtNewYr) = DOW - 1 And LeapYear) Then
basNumDOW_Simple = 53
Exit Function
End If
basNumDOW_Simple = 52
End Function