From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Ian Barwick <barwick(at)gmail(dot)com> |
Cc: | Patrick Fiche <patrick(dot)fiche(at)aqsacom(dot)com>, Scott Nixon <snixon(at)lssi(dot)net>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Help with syntax for timestamp addition |
Date: | 2004-11-22 15:26:55 |
Message-ID: | 200411221626.55515.peter_e@gmx.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ian Barwick wrote:
> On Mon, 22 Nov 2004 15:12:26 +0100, Patrick Fiche
>
> <patrick(dot)fiche(at)aqsacom(dot)com> wrote:
> > Have a try at this syntax
> >
> > SELECT number
> > FROM procedures
> > WHERE date + CAST( numdays || ' days' AS interval ) <=
> > CURRENT_TIMESTAMP;
>
> Just for the record you could write it like this too:
> SELECT number
> FROM procedures
> WHERE date + (numdays || ' days')::interval <= CURRENT_TIMESTAMP;
Just to add to the record, the mathematically sound way to write this
query would be this:
SELECT number
FROM procedures
WHERE date + numdays * interval '1 day' <= current_timestamp;
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Nixon | 2004-11-22 15:33:29 | Re: Help with syntax for timestamp addition |
Previous Message | Ian Barwick | 2004-11-22 15:02:07 | Re: Help with syntax for timestamp addition |