| From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
|---|---|
| To: | "Madhavi Daroor" <madhavi(at)zoniac(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: TIMESTAMP SUBTRACTION |
| Date: | 2003-05-21 14:50:45 |
| Message-ID: | 7078.1053528645@sss.pgh.pa.us |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
"Madhavi Daroor" <madhavi(at)zoniac(dot)com> writes:
> I need to compare this difference with a numeric value in my WHERE clause
> like this
> WHERE
> TIMESTAMP('05-21-2003 00:00:00','mm-dd-yyyy') - TO_TIMESTAMP('04-30-200300:00:00','mm-dd-yyyy') > 30
And what is the "30" supposed to mean? Seconds, days, fortnights, ... ?
If it's a constant you'd be better off to write it as an interval
constant:
... > interval '30 days'
(or whatever unit you have in mind). If it's not constant you might
try this way:
... > 30 * interval '1 day'
since there is a float-times-interval-yielding-interval operator.
regards, tom lane
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2003-05-21 15:11:28 | Re: TIMESTAMP SUBTRACTION |
| Previous Message | alex b. | 2003-05-21 14:49:03 | Re: Fwd: Re: mod_perl + PostgreSQL implementation |