From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Neil Zanella <nzanella(at)cs(dot)mun(dot)ca> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: incrementing and decrementing dates by day increments |
Date: | 2003-10-26 21:31:46 |
Message-ID: | 20031026132910.R7424@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Sat, 25 Oct 2003, Neil Zanella wrote:
> Hello,
>
> I know that PostgreSQL, like most database management systems, has a
> function
> call called NOW() that returns the current date. Is there a way to
> return a datein PostgreSQL such that the output is in ISO 8601 format
> (Unix 'date -I' format)but such that the date is not "today"'s date
> but the date two days ago or five
> days ahead of now? I have tried something like NOW() + 5 but that did
> not work
> (because the data types are incompatible, and SELECT NOW() +
> '0000-00-01' does
> not work either. I get the error:
If you want a date, I'd suggest something like
CURRENT_DATE+5
The reason this works while, now()+5 doesn't is that now() doesn't return
a date, but a timestamp type (including time).
If you want time information, then probably
CURRENT_TIMESTAMP + INTERVAL '5 days'
From | Date | Subject | |
---|---|---|---|
Next Message | John DeSoi | 2003-10-26 21:41:16 | Re: shared memory on OS X - 7.4beta4 |
Previous Message | Alvaro Herrera | 2003-10-26 20:33:29 | Re: incrementing and decrementing dates by day increments programmatically |