Re: Age function

From: "Mihai Gheorghiu" <tanethq(at)earthlink(dot)net>
To: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Age function
Date: 2002-10-11 13:36:46
Message-ID: 001201c2712b$3eb86700$6e646464@New6.Travel
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks for the daylight savings tip. However:

SELECT age('10/10/02' :: date, '1/10/02' :: date);
8mons 30days 23:00

SELECT age(date('10/10/02'), date('1/10/02'));
8mons 30days 23:00

When I cast to date, I should get 9 months.
It looks like it works timestamp, with hours and fractions thereof set to
zero. It should not take into account daylight savings, either.
I searched the archives, and this topic has come up more than once over the
past two years.

-----Original Message-----
From: Joe Conway <mail(at)joeconway(dot)com>
To: Mihai Gheorghiu <tanethq(at)earthlink(dot)net>
Cc: pgsql-general(at)postgresql(dot)org <pgsql-general(at)postgresql(dot)org>
Date: Thursday, October 10, 2002 6:09 PM
Subject: Re: [GENERAL] Age function

>Mihai Gheorghiu wrote:
>> PG7.2.1 on RH7.3
>>
>> SELECT AGE ('10/10/02', '1/10/02');
>> 8mons 30days 23:00
>>
>> SELECT AGE ('10/10/02 4:00PM', '1/10/02');
>> 9mons 15:00
>>
>> Please help.
>> Thank you all.
>
>Not clear what you think the problem is. If it is the apparent 1 hr
>discrepancy, I think that is due to the fact that January 10th is
"standard"
>time for your timezone whereas October 10th is still "daylight savings"
time.
>Try two dates within daylight savings time:
>
>test=# SELECT AGE ('10/10/02 4:00PM', '7/10/02');
> age
>--------------
> 3 mons 16:00
>(1 row)
>
>test=# SELECT AGE ('10/10/02', '7/10/02');
> age
>--------
> 3 mons
>(1 row)
>
>Looks correct to me.
>
>Joe
>
>
>

Browse pgsql-general by date

  From Date Subject
Next Message Rod Taylor 2002-10-11 13:36:52 Re: MySQL vs PostgreSQL.
Previous Message Antti Haapala 2002-10-11 13:20:22 MySQL vs PostgreSQL.