Possible age() bug?

Started by Mitch Vincentover 25 years ago2 messages
#1Mitch Vincent
mitch@venux.net

Maybe I'm just overlooking something really simple but this has me a bit
confused.

What I'm trying to do is get the amount of time from A to B -- I thought
age() would do just that but it seems to be about a day off sometimes.

hhs=# SELECT age('Sun Dec 03 08:00:00 2000 EST','Tue Oct 10 08:00:00 2000
EDT') as esec;
esec
------------------------
@ 1 mon 24 days 1 hour
(1 row)

Ok, but if I turn right around and add that value back , I get :

hhs=# SELECT ('Tue Oct 10 08:00:00 2000 EDT'::timestamp + '1 mon 24 days 1
hour'::interval);
?column?
------------------------------
Mon Dec 04 08:00:00 2000 EST
(1 row)

Like I said, perhaps I'm blind and can't see what's happening here but
shouldn't that be Sunday the 3rd of December?

I should point out that it works as I expected it to on other values..

hhs=# SELECT age('Sun Nov 05 08:00:00 2000 EST','Tue Oct 10 08:00:00 2000
EDT') as esec;
esec
------------------
@ 26 days 1 hour
(1 row)

hhs=# SELECT ('Tue Oct 10 08:00:00 2000 EDT'::timestamp + '1 mon 24 days 1
hour'::interval);
?column?
------------------------------
Mon Dec 04 08:00:00 2000 EST
(1 row)

*shrug*

Thanks!

-Mitch

#2Mitch Vincent
mitch@venux.net
In reply to: Mitch Vincent (#1)
Re: Possible age() bug?

I should point out that it works as I expected it to on other values..

hhs=# SELECT age('Sun Nov 05 08:00:00 2000 EST','Tue Oct 10 08:00:00 2000
EDT') as esec;
esec
------------------
@ 26 days 1 hour
(1 row)

hhs=# SELECT ('Tue Oct 10 08:00:00 2000 EDT'::timestamp + '1 mon 24 days 1
hour'::interval);
?column?
------------------------------
Mon Dec 04 08:00:00 2000 EST
(1 row)

I was obviously on drugs when I put this in the email, I apologize. It does
indeed work as I expected it to on other values.

In an old 6.4 database I get what I expected ::

hhs=> SELECT age('Sun Dec 03 08:00:00 2000 EST','Tue Oct 10 08:00:00 2000
EDT') as esec;
esec
----------------------
@ 1 mon 24 days 1 hour
(1 row)

hhs=> SELECT ('Tue Oct 10 08:00:00 2000 EDT'::timestamp + '1 mon 24 days 1
hour'::interval);
?column?
----------------------------
Sun Dec 03 07:00:00 2000 CST
(1 row)

(Timezone differences are there and expected, these boxes are all across the
country).

-Mitch