From: | Jasen Betts <jasen(at)xnet(dot)co(dot)nz> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Leap Years |
Date: | 2010-02-26 08:45:58 |
Message-ID: | hm81o6$sg7$1@reversiblemaps.ath.cx |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On 2010-02-25, Atif Jung <atifjung(at)gmail(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Jasen Betts | 2010-02-26 08:52:14 | Re: Leap Years |
Previous Message | A. Kretschmer | 2010-02-26 05:51:27 | Re: Importing lines of variable length from ASCII |