Re: Having trouble with Interval computation

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: Having trouble with Interval computation
Дата
Msg-id 3B536258.4832845B@fourpalms.org
обсуждение исходный текст
Ответ на Having trouble with Interval computation  ("Jim Ballard" <jballard@netezza.com>)
Список pgsql-general
> I'd like to get the difference between two timestamp columns expressed
> as an interval with units "year to month."
...
> What is the proper way to express this in Postgres?  Will the standard
> form be supported at some point?

lockhart=# select age('today', '1957-06-13');
          age
-----------------------
 44 years 1 mon 3 days
(1 row)

lockhart=# select date_trunc('month', age('today', '1957-06-13'));
   date_trunc
----------------
 44 years 1 mon
(1 row)

Note that if the age() function is not used, and instead you use the
subtraction operator, then the result is zero, since the operator gives
a days/hours/min/sec result and does not preserve *any* year or month
information.

"Standard form", that is SQL9x rather than Ingres, will likely be
supported at some point, maybe sooner rather than later if the syntax
can fit into our parser.

hth

                      - Thomas

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

Предыдущее
От: Janning Vygen
Дата:
Сообщение: Application Design and PostgreSQL
Следующее
От: Oleg Bartunov
Дата:
Сообщение: Re: [HACKERS] Translators wanted