From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
---|---|
To: | John D(dot) Burger <john(at)mitre(dot)org> |
Cc: | PostgreSQL General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: date time function |
Date: | 2007-06-29 19:06:28 |
Message-ID: | 616D362B-3BEB-4BF8-90D7-824F36A3D2F4@seespotcode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Jun 29, 2007, at 13:17 , John D. Burger wrote:
> 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
Without being anchored with a timestamp, we have no way to know how
long a given month is in the result, so it plays it safe by returning
everything in days.
> 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?
The timestamp[tz]_age functions currently don't use the same
algorithm the timestamp_mi code does. This should probably be
reconciled in the future so results are consistent.
> But age() is documented as simply producing an interval - where is
> the magic that makes the first and third results above look different?
src/backend/utils/adt/timestamp.c
> Ah, wait a minute - does this have to do with the varying number of
> days in different months?
Yes.
Michael Glaesemann
grzm seespotcode net
From | Date | Subject | |
---|---|---|---|
Next Message | Gauthier, Dave | 2007-06-29 19:16:13 | How does one impolement lists, or arrays, pin pl/pgsql ? |
Previous Message | Tom Lane | 2007-06-29 18:58:35 | Re: date time function |