From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | BlakJak <blakjak(at)blakjak(dot)sytes(dot)net> |
Cc: | Neil Zanella <nzanella(at)cs(dot)mun(dot)ca>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: incrementing and decrementing dates by day increments |
Date: | 2003-10-27 06:47:11 |
Message-ID: | 22977.1067237231@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
BlakJak <blakjak(at)blakjak(dot)sytes(dot)net> writes:
> So to get "five days ago", you would use
> now() - interval '5 days'
Actually, given that the OP seems to only want a date result and not a
time-of-day, I'd suggest something like
current_date - 5
The date-plus-integer and date-minus-integer operators do exactly what
I think is being asked for. timestamp-minus-interval does computations
including fractional days, which will just confuse matters
... especially near DST transition days. For instance, right now I get
regression=# select now();
now
-------------------------------
2003-10-27 01:45:14.458268-05
(1 row)
regression=# select now() - interval '5 days';
?column?
------------------------------
2003-10-22 02:45:20.22788-04
(1 row)
which is correct in one sense but is surely going to confuse some
people.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Yonatan Goraly | 2003-10-27 07:59:35 | Re: Slow query |
Previous Message | Tom Lane | 2003-10-27 06:04:49 | Re: foxpro to postgresql7.1 |