leap year

skate

Registered User.
Local time
Today, 09:41
Joined
May 22, 2002
Messages
136
is there a function that returns a value indicating whether an inputted date is a leap year or not?
 
You can use the IsDate() function to test for the existence of a Feb 29 in that year, for example

IIf(IsDate("29/2/" & Year(InputtedDate)), "Leap year", "Not leap year")


You can even build your own function in a module, for example

Public Function IsLeapYear(InputtedDate As Variant) As Boolean

If Not IsDate(InputtedDate) Then
IsLeapYear = False
ElseIf Not IsDate("29/2/" & Year(InputtedDate)) Then
IsLeapYear = False
Else
IsLeapYear = True
End If

End Function
 

Users who are viewing this thread

Back
Top Bottom