Re: TIMESTAMP SUBTRACTION - Mailing list pgsql-general

From Tom Lane
Subject Re: TIMESTAMP SUBTRACTION
Date
Msg-id 7078.1053528645@sss.pgh.pa.us
Whole thread Raw
In response to TIMESTAMP SUBTRACTION  ("Madhavi Daroor" <madhavi@zoniac.com>)
List pgsql-general
"Madhavi Daroor" <madhavi@zoniac.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

pgsql-general by date:

Previous
From: "alex b."
Date:
Subject: Re: Fwd: Re: mod_perl + PostgreSQL implementation
Next
From: Alvaro Herrera
Date:
Subject: Re: TIMESTAMP SUBTRACTION