Re: date time function

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: date time function
Date: 2007-06-29 18:17:35
Message-ID: C4E2800F-7F62-4526-8739-CB08DD78B22B@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Dorbath 2007-06-29 18:24:02 Re: db replication
Previous Message Erik Jones 2007-06-29 17:47:07 Re: Standby servers and incrementally updated backups