Re: Leap Years - Mailing list pgsql-novice

From Jasen Betts
Subject Re: Leap Years
Date
Msg-id hm81o6$sg7$1@reversiblemaps.ath.cx
Whole thread Raw
In response to Leap Years  (Atif Jung <atifjung@gmail.com>)
List pgsql-novice
On 2010-02-25, Atif Jung <atifjung@gmail.com> wrote:
> --0016e6daaff9970fd004806fd4d9
> Content-Type: text/plain; charset=ISO-8859-1
>
> INFORMIX uses the rleapyear(year) ESQLC function to determine if a year is a
> leap year or not. Does POSTGRES have an equivalent?

not yet.

CREATE FUNCTION rleapyear(integer) RETURNS BOOLEAN AS $$
 select extract( day from ( $1 || '-02-28' ) :: date + '1 day'::interval) != 1
$$ LANGUAGE SQL;

it does now!  years less than 1900 may give non-useful results locale
dependant, years less that 1600 will not work right.

I can't immagine when a function like that would be more useful than
just doing date arithmetic using intervals.


pgsql-novice by date:

Previous
From: "A. Kretschmer"
Date:
Subject: Re: Importing lines of variable length from ASCII
Next
From: Jasen Betts
Date:
Subject: Re: Leap Years