|
'? firstDayOfMonth("2003-2-4")
' 2003-2-1
'? lastDayOfMonth("2003-2-4")
' 2003-2-28
'? DaysInMonth("2003-2-4")
' 28
Function firstDayOfMonth(myDate As Date) As Date
firstDayOfMonth = CDate(Format(myDate, "yyyy-m-1"))
End Function
Function lastDayOfMonth(myDate As Date) As Date
lastDayOfMonth = DateAdd("d", -1, DateAdd("M", 1, firstDayOfMonth(myDate)))
End Function
Function DaysInMonth(myDate As Date) As Integer
DaysInMonth = DateDiff("d", firstDayOfMonth(myDate), lastDayOfMonth(myDate)) + 1
End Function
|
|