From: | Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> |
---|---|
To: | Madhavi Daroor <madhavi(at)zoniac(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: TIMESTAMP SUBTRACTION |
Date: | 2003-05-21 15:11:28 |
Message-ID: | 20030521151128.GB2283@dcc.uchile.cl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, May 21, 2003 at 04:27:32PM +0530, Madhavi Daroor wrote:
> 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.
One thing you can try is to convert the timestamps to dates, and
substract that. It'll return a numerical value.
regression=# select to_date('2003-04-99', 'yyyy-mm-dd') -
to_date('2002-13-85', 'yyyy-mm-dd') > 100;
?column?
----------
t
(1 row)
--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"I think my standards have lowered enough that now I think 'good design'
is when the page doesn't irritate the living fuck out of me." (JWZ)
From | Date | Subject | |
---|---|---|---|
Next Message | scott.marlowe | 2003-05-21 15:22:46 | Re: caching query results |
Previous Message | Tom Lane | 2003-05-21 14:50:45 | Re: TIMESTAMP SUBTRACTION |