Xavier
The semantics of extract is that it will give the month/hour/minute
of the interval, not the number of months/hours/days of the interval
Dave
On 22-Mar-06, at 11:25 AM, Xavier Poinsard wrote:
> Dave Cramer a écrit :
>>> You are right, but I would not expect 0 with :
>>>
>>> select extract(month from
>>> (current_date+ interval '3 month'-current_date));
>>>
>>> date_part
>>> -----------
>>> 0
>>> (1 row)
>>
>>
>> This is still an interval basically you have
>>
>> date + interval - date which will be an interval. date - date is an
>> interval
>
> I think the interval implementation is bit deficient, since it only
> keeps one unit. Instead of keeping only the difference in days, it
> could
> have keep the information in month too.
>
> test=> select (current_date+interval '3 month'-current_date);
> ?column?
> ----------
> 92 days
> (1 row)
>
> test=> select extract(month from (interval '3 month'));
> date_part
> -----------
> 3
> (1 row)
>
> select extract(month from (interval '1 year'));
> date_part
> -----------
> 0
> (1 row)
>