Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Calculation of Leap Year
ats wrote:
> Satish wrote:
> > IS there any way in PL/SQL to identify an year as a Leap Year?
>
> CREATE OR REPLACE FUNCTION is_leap_year (yearstr VARCHAR2)
> RETURN BOOLEAN IS
>
> d DATE;
>
> BEGIN
> d := TO_DATE('29-FEB-' || yearstr);
> RETURN TRUE;
> EXCEPTION
> WHEN OTHERS THEN
> RETURN FALSE;
> END;
> /
I'd write it as d := TO_DATE('29-FEB-' || yearstr, 'dd=MON-yyyy');
That way it won't break if someone changes the default date format.
-- //-Walt // //Received on Mon Oct 11 2004 - 08:23:44 CDT