Leap year by using User Defined functions
Function:
CREATE FUNCTION [dbo].[LeapYear] ( @Date DATETIME )
RETURNS VARCHAR(100)
AS
BEGIN
IF (YEAR( @Date ) % 4 = 0 AND YEAR( @Date ) % 100 != 0) OR
YEAR( @Date ) % 400 = 0
RETURN 'Leap Year'
RETURN 'Non-Leap Year'
END
GO
To execute the above function
select [dbo].[LeapYear] ('2016')
Once you practice delete all these stuff
No comments:
Post a Comment