Let SQL Server tell you by using the IsDate function.
If IsDate('02/29/2000')=1
Print 'Is Leap Year'
Else
Print 'Is Not Leap Year'
Check the current year:
If isdate('02/29/'+cast(year(getdate()) As char(4)))=1
Print 'Is Leap Year'
Else
Print 'Is Not Leap Year'
Alternate syntax:
If IsDate('02/29/'+ltrim(str(year(getdate()))))=1
Print 'Is Leap Year'
Else
Print 'Is Not Leap Year' Terry L. Broadbent FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.