Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Calculation of Leap Year

Re: Calculation of Leap Year

From: Walt <walt_askier_at_YourShoesyahoo.com>
Date: Mon, 11 Oct 2004 09:23:44 -0400
Message-ID: <416A8960.6BC293EA@YourShoesyahoo.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US