Finding Leap year in Teradata

Database
Enthusiast

Finding Leap year in Teradata

Hi,

Is there any built-in function to find Leap year in teradata?

Thanks,

Vinay.

2 REPLIES
Enthusiast

Re: Finding Leap year in Teradata

Vinay,

Not a function but this will work

sel year_of_calendar from sys_calendar.calendar where day_of_month = 29 and month_of_year = 2;

Rglass

Junior Supporter

Re: Finding Leap year in Teradata

REPLACE 
FUNCTION IS_LEAP_YEAR (the_year INTEGER)
RETURNS BYTEINT
LANGUAGE SQL
CONTAINS SQL
DETERMINISTIC
SQL SECURITY DEFINER
COLLATION INVOKER
INLINE TYPE 1
RETURN CASE WHEN the_year MOD 4 = 0
             AND ( the_year MOD 100 <> 0 OR the_year MOD 400 = 0)
               THEN 1
            ELSE 0
       END
;

HTH.

Cheers

Carlos