All Forums Database
Vinay151 20 posts Joined 12/14
28 May 2015
Finding Leap year in Teradata

Hi,
Is there any built-in function to find Leap year in teradata?
 
Thanks,
Vinay.

Glass 225 posts Joined 04/10
29 May 2015

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
 

CarlosAL 512 posts Joined 04/08
29 May 2015
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
 

You must sign in to leave a comment.