Try this to Test for Leap Year
Dear All,
[B][COLOR="Indigo"]Test for Leap Years[/COLOR][/B]
[B][COLOR="DarkOrange"]select year,
decode( mod(year, 4), 0,
decode( mod(year, 400), 0, 'Leap Year',
decode( mod(year, 100), 0, 'Not a Leap Year', 'Leap Year')
), 'Not a Leap Year'
) as leap_year_indicator
from my_table[/COLOR][/B]
Have a pleasant time
:)
Re: Try this to Test for Leap Year
What about simply using this one.
[code]
SELECT DECODE(TO_CHAR(LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE,' y'),1)),'DD'),28 ,'Not a Leap Year','Leap Year') FROM dual
[/code]
Re: Try this to Test for Leap Year
Try this also
[CODE]SELECT DECODE((LAST_DAY(ADD_MONTHS(TRUNC(SYSDATE,'YYYY'),11)) - TRUNC(SYSDATE,'YYYY'))+1,365,'NOT A LEAP YEAR',366,'LEAP YEAR') FROM DUAL;[/CODE]