Welcome

Hello, Welcome to my blog. If you like feel free to refer others

Monday, 23 January 2012

Create a function to determine Leap year or not

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



Happy Learning........

No comments:

Post a Comment