Functin - How to Get Leap Year

/*Detecting leap year*/
CREATE FUNCTION dbo.IsLeapYear(@Year int)
RETURNS bit
AS
BEGIN
DECLARE @RetVal bit
IF (@Year % 400) = 0 --//every 400 years
SET @RetVal = 1
ELSE
BEGIN
IF (@Year % 100) = 0
SET @RetVal = 0
ELSE
BEGIN
IF (@Year % 4) = 0
SET @RetVal = 1
ELSE
SET @RetVal = 0
END
END
RETURN @RetVal
END
GO

No comments: