Be Tech Savvy…
User Defined Function to Check Leap Year In MS SQL Server
To find out Leap year is use to be a small assignment. Its a very popular question and I’m sure we all have done it from different different programming languages. We all have used some predefined functions to solve this. Today we will see how to write a User Defined Function for checking Leap Year but from MS SQL Server.
CREATE FUNCTION [dbo].[fn_CheckLeapYear] ( @InputDate DATETIME )
RETURNS BIT
AS
BEGINIF ( YEAR(@InputDate) % 4 = 0
AND YEAR(@InputDate) % 100 != 0
)
OR YEAR(@InputDate) % 400 = 0
RETURN 1RETURN 0
END
Note : Above function will return bit value.
Very good boss