How do I check if a year is a leap year?
I have this code:
declare @year int set @year = 1968 SELECT CASE WHEN @YEAR = THEN \'LEAP
Not sure how efficient this is compared to the other solutions. But is another option.
DECLARE @year int = 2016 SELECT CASE WHEN DATEPART(dayofyear, DATEFROMPARTS(@year, 12, 31)) = 366 THEN 'LEAP' ELSE 'NOT LEAP' END