Skip site navigation (1) Skip section navigation (2)

Re: Leap Years

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 (view raw or flat)
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.


In response to

  • Leap Years at 2010-02-25 17:08:03 from Atif Jung

pgsql-novice by date

Next:From: Jasen BettsDate: 2010-02-26 08:52:14
Subject: Re: Leap Years
Previous:From: A. KretschmerDate: 2010-02-26 05:51:27
Subject: Re: Importing lines of variable length from ASCII

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group