Create a function to check leap year
create FUNCTION CHECK_LEAP_YEAR
DECLARE @leapdate SMALLDATETIME
DECLARE @check_day TINYINT
SET @leapdate = CONVERT(VARCHAR(4), @year) + '0228'
SET @check_day = DATEPART(d, DATEADD(d, 1, @leapdate))
IF (@check_day = 29)
SELECT dbo.CHECK_LEAP_YEAR(2000) as checkLeapYear
run abopve query
pass the year, if it is leap year the result will be returned as 1 if not then 0.
if it will review by Editors
This also a one type of method to find Leap Year
select case (YEAR(getdate()))%4 when 0 then 'Leap Year' else 'Not Leap Year' end as Leap
Hi Mohan ,
Your query is wrong.
Every year which is divisible by 4 isn't a leap year.
This is logic
if(yr%400 == 0) || ((yr%4 == 0) && (yr%100 != 0))
So i have written some logic in that function.
Yes i accept . Thanks for your information..