Alban Hertroys wrote:
> Look here:
>
> template1=> select age(now() + '01:30:00'::interval);
> age
> ------------------
> -17:02:41.247957
> (1 row)
>
> 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>
First of all, the "17" is hours, not days. Look again at the formatted
output.
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')
(my current time, 10:02:01.727674-04, is different from what yours was,
obviously)
Looking that the output from :
select
age(now() + '01:30:00'::interval),
now(),
current_date::timestamp,
current_time,
age(current_date, now() + '01:30:00'::interval),
age(now() + '01:30:00'::interval, current_date),
age(now() + '01:30:00'::interval, now())
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>
Regards,
Berend Tober
begin:vcard
fn:Berend Tober
n:Tober;Berend
org:Seaworthy Systems, Inc.
adr:;;22 Main Street;Centerbrook;CT;06409;USA
email;internet:btober@xxxxxxxxxxxxxxxx
tel;work:860-767-9061
url:http://www.seaworthysys.com
version:2.1
end:vcard