dbTalk Databases Forums  

[BUGS] Ambiguous behaviour of age(timestamp)

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] Ambiguous behaviour of age(timestamp) in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kouber Saparev
 
Posts: n/a

Default [BUGS] Ambiguous behaviour of age(timestamp) - 11-29-2004 , 12:30 PM






Hello,

As the documentation describes the AGE() function -
http://developer.postgresql.org/docs...DATETIME-TABLE ,
there are two signatures:
- AGE(timestamp);
- AGE(timestamp, timestamp).

I think the documentation is misleading, because AGE(timestamp) is actually
converted to AGE(current_date, timestamp), and not to AGE(now(), timestamp).
So for example:
test=> select age(now());
age
------------------
-17:23:32.589739
(1 row)

I'm actually receiving the *age* of now() compared to the start of the day
0:00. Thus:
test=> select age(now() - interval '1 day');
age
-----------------
06:34:45.945311
(1 row)

returns not an age of 1 day but the age of yesterday's timestamp compared to
0:00 of today.

However:
test=> select age(now(), now() - interval '1 day');
age
-------
1 day
(1 row)

Which is correct.

As I initially understood the docs, the second form of age(timestamp,
timestamp) is the same as the first one - age(timestamp), with the exception
that the counting is not started from *today* but from custom timestamp
instead; and because the arguments are of type 'timestamp' and not 'date' I
supposed that now() is applied as a default first argument.

I am not sure what is the right behaviour of this function (I think it's not
correct now), but at least there have to be some explanations in the
documentation.

Regards,
Kouber Saparev


---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.