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 dtNthDOW(dtDtIn As Date, intNthWkDay, Optional intDOW As Integer = vbFriday) As Date
'Michael Red 11/8/2003 Return the Date of the Nth Day of the Week _
in the Month of the input date. Minimal error checking, Returns Sone _
date in the year of 1899 if the Nth Day of the Week does not fall in _
the same month as the date in.
'Example of a normal return
'? dtNthDOW(DAte, 3)
'11/21/03
'Example of an error return
'? dtNthDOW(DAte, 6, vbsunday)
'12/29/1899
Dim dtFstOfMnth As Date
dtFstOfMnth = DateSerial(Year(dtDtIn), Month(dtDtIn), 1)
While Weekday(dtFstOfMnth) <> intDOW
dtFstOfMnth = dtFstOfMnth + 1
Wend
dtNthDOW = DateAdd("d", (intNthWkDay - 1) * 7, dtFstOfMnth)
If (Month(dtDtIn) <> Month(dtNthDOW)) Then
dtNthDOW = -1
End If
End Function
Function ThirdFriday(ByVal InputDate As Date) As Date
InputDate = DateSerial(Year(InputDate), Month(InputDate), 1)
ThirdFriday = InputDate + 21 - Weekday(InputDate, vbSaturday)
End Function