Expert Mod 8TB |
Ok, this may need some adapting. If the date passed is a Friday it should return the number of Fridays in that month. -
Function checkDays (chkDate As Date)
-
' Function to check the number of days in the month corresponding to this date
-
Dim tmpDay As Integer
-
Dim firstDayMth As Integer
-
Dim tmpMth As Integer
-
Dim mthDays As Integer
-
Dim tmpYr As Integer
-
Dim numDays As Integer
-
Dim i As Integer
-
-
tmpDay = Weekday(chkDate)
-
tmpMth = Month(chkDate)
-
tmpYr = Year(chkDate)
-
-
firstDayMth = Weekday(DateSerial(tmpYr, tmpMth, 1)) ' what day does first day of the month fall on
-
If firstDayMth = tmpDay Then i = 1
-
ElseIf firstDayMth < tmpDay Then i = tmpDay-firstDayMth
-
Else
-
i = firstDayMth-tmpDay
-
End If
-
-
' find total number of days in the month
-
If tmpMth IN (4,6,9,11) Then mthDays = 30
-
ElseIf tmpMth IN (1,3,5,7,8,10,12) Then mthDays = 31
-
ElseIf tmpMth = 2 Then mthDays = DatePart("d", DateSerial(tmpYr, 3, 1)-1)
-
-
Do While i <= mthDays
-
numDays = numDays + 1
-
i = i + 7
-
Loop
-
-
checkDays = numDays
-
-
End Function
-
Mary
| |