Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
itnagaraj
Yak Posting Veteran
70 Posts |
Posted - 2010-09-13 : 09:58:48
|
How to find leap year in sql queryV.NAGARAJAN |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-09-13 : 12:09:42
|
SQL server date functions take leap years into account. But the way you determine a leap year in SQL is the same as anywhere else. All years divisible by 4 are leap years (Year % 4) = 0 exceptif a year is divisible by 100 (year % 100) = 0, it is a leap year only if it is also divisible by 400 (year % 400) = 0JimEveryday I learn something that somebody else already knew |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-14 : 05:33:51
|
If the 60th day falls in February, it is a Leap yearselect case when month(dateadd(year,datediff(year,0,getdate()),0)+59)=2 then 'Leap year' else 'Non Leap year' endMadhivananFailing to plan is Planning to fail |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|