TIMESTAMP SUBTRACTION

From: "Madhavi Daroor" <madhavi(at)zoniac(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: TIMESTAMP SUBTRACTION
Date: 2003-05-21 10:57:32
Message-ID: NHBBKMLNGKEMDMCGAMFNAEHECAAA.madhavi@zoniac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi All,
When I subtract 2 timestamp variables in postgres 2.3.1, I get an
interval value.
Eg:
SELECT TO_TIMESTAMP('05-21-2003 00:00:00','mm-dd-yyyy') -
TO_TIMESTAMP('04-30-2003 00:00:00','mm-dd-yyyy');
Result:
21 days --------- This is an interval

But what I need is a numeric value. Ie; 21 and NOT 21 days.

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-2003
00:00:00','mm-dd-yyyy') > 30

But if I do this....I get wrong results. How do I do such a comparison? Or
How to I get a Numeric value after the subtraction?

Please reply SOON !!!

Thanx,
Madhavi Daroor

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John Schickling 2003-05-21 11:07:41 psql and ssl.
Previous Message Nigel J. Andrews 2003-05-21 09:58:26 Re: SELECT DISTINCT ON bug?