RMTWeb

View Original

ASP Functions - getDaysInMonth

As the title of this function I wrote explains - this function returns the number of days in a month

Usage: getDaysInMonth( 12, 2006) would return the number of days in December 2006 - 31

Function getDaysInMonth(strMonth,strYear)
Dim strDays
Select Case cint(strMonth)
Case 1,3,5,7,8,10,12:
strDays = 31
Case 4,6,9,11:
strDays = 30
Case 2:
if ((cint(strYear) mod 4 = 0 and _
cint(strYear) mod 100 <> 0) _
or ( cint(strYear) mod 400 = 0) ) then
strDays = 29
else
strDays = 28
end if
End Select
getDaysInMonth = strDays

End Function