Public Function ThirdFriday(DT As Date) As Date
Dim DL As Date
Dim DA As Integer
DL = DateSerial(Year(DT), Month(DT), 1)
DA = WeekDay(DL, 7)
ThirdFriday = DateAdd("d", 21 - DA, DL)
End Function
Well, the 3rd Friday could be from the 15th to the 21st.
Public Function ThirdFriday(intMonth As Integer, intYear As Integer) As Date
Dim i As Integer, dteTempDate As Date
For i = 15 To 21
dteTempDate = DateSerial(intYear, intMonth, i)
If WeekDay(dteTempDate) = vbFriday Then
ThirdFriday = dteTempDate
Exit For
End If
Next i
End Function
--
Wayne Morgan
MS Access MVP
SHIPP said:
Does anybody know the code to determine what the date is of the 3rd Friday
Never write code when you can build a table, that's what *I* always
say.
SELECT Cal_Date, Cal_DOW, Cal_DOW_Ordinal
FROM Calendar
WHERE (Cal_DOW = 'Fri' AND
Cal_DOW_Ordinal = 3);
I left the structure of the calendar table as an exercise.
I used Excel to calculate the values once, put them under revision
control, then used a text-processing tool to generate SQL INSERT
statements from the values.
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.