Re: Having trouble with Interval computation - Mailing list pgsql-general

From Thomas Lockhart
Subject Re: Having trouble with Interval computation
Date
Msg-id 3B536258.4832845B@fourpalms.org
Whole thread Raw
In response to Having trouble with Interval computation  ("Jim Ballard" <jballard@netezza.com>)
List 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 by date:

Previous
From: Janning Vygen
Date:
Subject: Application Design and PostgreSQL
Next
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] Translators wanted