leap year

skate

Registered User.
Local time
Today, 09:19
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?
 
No, but if you let Access validate the date, it will give you an error if the entered date is invalid.

However, if you want to do it yourself, the rule is the 4-digit year must be evenly divisible by 4 but NOT by 100 unless the year is divisible by 400. So 1600 and 2000 are leap years but 1700, 1800, and 1900 are not. The next century leap year will be 2400.
 
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