Search Postgresql Archives

Re: Age function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx

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 //


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux