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: ats <damorgan_at_x.washington.edu>
Date: Mon, 11 Oct 2004 20:44:09 -0700
Message-ID: <1097552599.809495@yasure>


Walt wrote:

> 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.

Good observation. Thanks.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Mon Oct 11 2004 - 22:44:09 CDT

Original text of this message

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