Friday, September 21, 2012

Check given Year is Leap year or Not in Sql Server?

create function dbo.fn_IsLeapYear (@year int)
returns bit
as
begin
return(select case datepart(mm, dateadd(dd, 1, cast((cast(@year as varchar(4)) + '0228') as datetime)))
when 2 then 1
else 0
end)
end
go


No comments:

Post a Comment