[prev in list] [next in list] [prev in thread] [next in thread] 

List:       postgresql-general
Subject:    Re: [GENERAL] date time function
From:       Michael Glaesemann <grzm () seespotcode ! net>
Date:       2007-06-29 19:06:28
Message-ID: 616D362B-3BEB-4BF8-90D7-824F36A3D2F4 () seespotcode ! net
[Download RAW message or body]


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



---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic