Hi Jenny,
Try this
In Module. add new
put in the code below
Function DaysofMonth(mydate)
If IsDate(mydate) Then
If DatePart("m", mydate) = 1 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 2 Then
If Int(DatePart("yyyy", mydate) / 4) - DatePart("yyyy", mydate) = 0 Then
DaysofMonth = 29
Else
DaysofMonth = 28
End If
ElseIf DatePart("m", mydate) = 3 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 4 Then
DaysofMonth = 30
ElseIf DatePart("m", mydate) = 5 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 6 Then
DaysofMonth = 30
ElseIf DatePart("m", mydate) = 7 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 8 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 9 Then
DaysofMonth = 30
ElseIf DatePart("m", mydate) = 10 Then
DaysofMonth = 31
ElseIf DatePart("m", mydate) = 11 Then
DaysofMonth = 30
ElseIf DatePart("m", mydate) = 12 Then
DaysofMonth = 31
End If
End If
Use it where ever needed eg
on a command button
like
Dim DinMonth As Integer
DinMonth = DaysofMonth(mydate)