Check for leap year
MOST EFFICIENT LEAP YEAR TEST:
CASE WHEN @YEAR & 3 = 0 AND (@YEAR % 25 <> 0 OR @YEAR & 15 = 0) THEN ...
Adapted from: http://stackoverflow.com/a/11595914/3466415
Leap year calculation:
(@year % 4 = 0) and (@year % 100 != 0) or (@year % 400 = 0)
When this is true, then it is a leap year. Or to put it in case statement
select case when
(
(@year % 4 = 0) and (@year % 100 != 0) or
(@year % 400 = 0)
) then 'LEAP' else 'USUAL' end
;
Check for 29th Feb:
CASE WHEN ISDATE(CAST(@YEAR AS char(4)) + '0229') = 1 THEN 'LEAP YEAR' ELSE 'NORMAL YEAR' END
or use the following rule
CASE WHEN (@YEAR % 4 = 0 AND @YEAR % 100 <> 0) OR @YEAR % 400 = 0 THEN 'LEAP YEAR'...