Re: TIMESTAMP SUBTRACTION

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: TIMESTAMP SUBTRACTION
Дата
Msg-id 20030521151128.GB2283@dcc.uchile.cl
обсуждение исходный текст
Ответ на TIMESTAMP SUBTRACTION  ("Madhavi Daroor" <madhavi@zoniac.com>)
Список 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)

В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: TIMESTAMP SUBTRACTION
Следующее
От: Darren Ferguson
Дата:
Сообщение: Re: TIMESTAMP SUBTRACTION