generate weeks of a month

B

Brendan Reynolds

Well, it depends on what exactly you mean by 'weeks in month'. If you mean
number of days in the month divided by seven, then the following code will
do it ...

Public Function WeeksInMonth(ByVal Month As Long, _
ByVal Year As Long) As Double

Select Case Month
Case 1, 3, 5, 7, 8, 10, 12
WeeksInMonth = 4.42857142857143
Case 4, 6, 9, 11
WeeksInMonth = 4.28571428571429
Case Else
'February, varies depending if leap year.
WeeksInMonth = (DateDiff("d", DateSerial(Year, Month, 1), _
DateSerial(Year, Month + 1, 1))) / 7
End Select

End Function
 
J

John Vinson

how to generate weeks in month using MS-ACCESS

Please explain your question. Do you want to convert a date to a week
number? What constitutes "the first" week of a month? The week
containing the first Monday, the first Sunday, any day during the
week?

John W. Vinson[MVP]
 
Top