Re: Age function

From: Alban Hertroys <alban(at)magproductions(dot)nl>
To: Berend Tober <btober(at)seaworthysys(dot)com>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Age function
Date: 2006-05-17 16:07:30
Message-ID: 446B4A42.1050103@magproductions.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Berend Tober wrote:
> Alban Hertroys wrote:
> > So, One and a half hour in the future is actually 17 days ago?
> > Interesting... Either I am doing something wrong, or postgres is, I have
> > my suspicions ;)
>
> <good-natured sarcasm>Your suspicions are correct that you are doing, or
> rather, understanding something incorrectly. </good-natured sarcasm>

No sarcasm needed, that was exactly what I was referring to ;)

> First of all, the "17" is hours, not days. Look again at the formatted
> output.

Yeah, I "corrected" myself after reading an example in the docs where
the age between two dates was calculated (as opposed to timestamps), and
figured I must've misread that as hours while they were days. That colon
pretty much nails it down as hours though. Silly me...

> Secondly, there are two forms of AGE, taking, respectively two arguments
> and one argument. The latter is a shorthand for the former, assuming the
> current time as the base time. So in your query is equivalent to
>
> ('2006-05-17 00:00:00') - ('2006-05-17 10:02:01.727674-04' + '01:30:00')

Ok, I see now. Actually, now I read it back, the docs for age(timestamp)
say it calculates from current_date - I missed that earlier.

> Looking that the output from :
(...)
> might help, <professorial pontification>as would RTFM
> ("http://www.postgresql.org/docs/8.1/static/functions-datetime.html",
> Table 9-26. Date/Time Functions). </professorial pontification>

I've looked at that table so often that I figured I knew it from the top
of my head. Guess I was wrong...

Actually, IMO those tables could be a bit more readable if the borders
would be simple 1px lines and some padding is added left and right of
the cell contents.

Well, thanks for the pointers.

--
Alban Hertroys
alban(at)magproductions(dot)nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede

// Integrate Your World //

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2006-05-17 16:12:47 Re: [GENERAL] Querying libpq compile time options
Previous Message Ed L. 2006-05-17 15:48:44 Re: pg_dump index/constraint creation order