From: | Berend Tober <btober(at)seaworthysys(dot)com> |
---|---|
To: | Alban Hertroys <alban(at)magproductions(dot)nl> |
Cc: | Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Age function |
Date: | 2006-05-17 14:24:22 |
Message-ID: | 446B3216.30209@seaworthysys.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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
Attachment | Content-Type | Size |
---|---|---|
btober.vcf | text/x-vcard | 233 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | Christian Kratzer | 2006-05-17 14:29:58 | Re: GUI Interface |
Previous Message | Dave Page | 2006-05-17 14:21:43 | Re: GUI Interface |