Re: date time function - Mailing list pgsql-general

From John D. Burger
Subject Re: date time function
Date
Msg-id C4E2800F-7F62-4526-8739-CB08DD78B22B@mitre.org
Whole thread Raw
In response to Re: date time function  (Michael Glaesemann <grzm@seespotcode.net>)
Responses Re: date time function  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: date time function  (Michael Glaesemann <grzm@seespotcode.net>)
List pgsql-general
I can't anything in the docs that explain how intervals print out.
They seem to show like this:

 > select now() - '1990-01-01';
            ?column?
-------------------------------
6388 days 13:06:26.3605600595

or like this:

 > select now() - current_date;
     ?column?
-----------------
14:06:46.119788

unless you use age(), which supposedly also returns an interval:

 > select age(now(), '1990-01-01');
                    age
-----------------------------------------
17 years 5 mons 28 days 14:08:04.524803

Why do the first and third intervals print out differently?  I see
this in the docs for age:

   Subtract arguments, producing a "symbolic" result that uses years
and months

But age() is documented as simply producing an interval - where is
the magic that makes the first and third results above look
different?  Ah, wait a minute - does this have to do with the varying
number of days in different months?

Thanks.

- John D. Burger
   MITRE



pgsql-general by date:

Previous
From: Erik Jones
Date:
Subject: Re: Standby servers and incrementally updated backups
Next
From: Hannes Dorbath
Date:
Subject: Re: db replication