Date Time Function / Age

Поиск
Список
Период
Сортировка
Искать

Date Time Function / Age

От:
Alex <alex@meerkatsoft.com>
Дата:
Hi,
is there an easy way to get the Difference between 2 dates in Days... as 
an integer?

age('date1','date2') results in  x years y days or something similar. 
but I would like to
have the result in number of days as an integer.

Thanks for your help

Alex


Re: Date Time Function / Age

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Alex  writes:
> is there an easy way to get the Difference between 2 dates in Days... as 
> an integer?

Subtract 'em ...

regression=# select '2002-01-01'::date - '2001-01-01'::date;
 ?column?
----------
      365
(1 row)


			regards, tom lane

Re: Date Time Function / Age

От:
Bruno Wolff III <bruno@wolff.to>
Дата:
On Thu, Aug 28, 2003 at 23:09:44 +0900,
  Alex  wrote:
> Hi,
> is there an easy way to get the Difference between 2 dates in Days... as 
> an integer?
> 
> age('date1','date2') results in  x years y days or something similar. 
> but I would like to
> have the result in number of days as an integer.

If you subtract two dates (not timestamps) you will get an integer that is
the number of days difference in the dates.
FAQ