Re: Problem in age on a dates interval - Mailing list pgsql-sql

From Luis Sousa
Subject Re: Problem in age on a dates interval
Date
Msg-id 40FB8DC2.1080405@ualg.pt
Whole thread Raw
In response to Re: Problem in age on a dates interval  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Problem in age on a dates interval
List pgsql-sql
I worked around this problem returning the difference between the two 
dates, using extract doy from both.
Anyway, this will cause a bug on my code when changing the year. Any ideas?

Best regards,
Luis Sousa

Tom Lane wrote:

>Theodore Petrosky <tedpet5@yahoo.com> writes:
>  
>
>>wow.... at first I thought I had my head around a leap
>>year problem so I advanced your query a year....
>>    
>>
>
>I think what's going on here is a difference of interpretation about
>whether an "M months D days" interval means to add the months first
>or the days first.  For instance
>
>2005-02-18 plus 2 months = 2005-04-18, plus 24 days = 2005-05-12
>
>2005-02-18 plus 24 days = 2005-03-14, plus 2 months = 2005-05-14
>
>The timestamp-plus-interval operator is evidently doing addition the
>first way, but it looks like age() is calculating the difference in a
>way that implicitly corresponds to the second way.
>
>I have some vague recollection that this has come up before, but
>I don't recall whether we concluded that age() needs to be changed
>or not.  In any case it's not risen to the top of anyone's to-do list,
>because I see that age() still acts this way in CVS tip.
>
>            regards, tom lane
>
>
>  
>


pgsql-sql by date:

Previous
From: "SZUCS Gabor"
Date:
Subject: Re: How do I convice postgres to use an index?
Next
From: "Alexander M. Pravking"
Date:
Subject: Re: Problem in age on a dates interval