Noname > 27-08-10, 12:56 AM
Public Function FirstDayofMonth(intYr As Integer, intMth As Integer, intWeekday As Integer) As Date
Dim dteMonthStart As Date
Dim intDayofWeek As Integer, intIncrement As Integer
dteMonthStart = DateSerial(intYr, intMth, 1)
intDayofWeek = Weekday(dteMonthStart)
If intDayofWeek <= intWeekday Then
intIncrement = intWeekday - intDayofWeek
FirstDayofMonth = DateAdd("d", intIncrement, dteMonthStart)
Else
intIncrement = (7 - intDayofWeek) + intWeekday
FirstDayofMonth = DateAdd("d", intIncrement, dteMonthStart)
End If
End Function