Re: [BUGS] BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. - Mailing list pgsql-bugs

From Pietro Pugni
Subject Re: [BUGS] BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Date
Msg-id FDFDA51E-CE35-4C7A-B4D8-3EB6BDF88153@gmail.com
Whole thread Raw
In response to Re: [BUGS] BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.  (Pietro Pugni <pietro.pugni@gmail.com>)
List pgsql-bugs
Probably it should be worth it to implement a sort of age2(timestamp, timestamp) function that returns ages accounting for leap years, months, days and seconds, without changing the actual implementation of age(timestamp, timestamp).

This results also may be of interest:

1)
select age('2007-04-01'::date, '1917-04-01'::date);
                age                
-----------------------------------
 89 years 11 mons 29 days 23:00:00

2)
select age('2007-04-01'::timestamp without time zone, '1917-04-01'::timestamp without time zone);
   age    
----------
 90 years


3)
select age('2007-04-01'::timestamp without time zone, '1917-04-01'::date);
   age    
----------
 90 years

4)
select age('2007-04-01'::date, '1917-04-01'::timestamp without time zone);
   age    
----------
 90 years


I don’t know if the result of query 1) is the desired output of the age(timestamp, timestamp) function.
Casting to timestamp and all combinations of date provides the same result as queries 2), 3) and 4):

5)
select age('2007-04-01'::timestamp, '1917-04-01'::timestamp);
   age    
----------
 90 years

6)
select age('2007-04-01'::date, '1917-04-01'::timestamp);
   age    
----------
 90 years

7)
select age('2007-04-01'::timestamp, '1917-04-01'::date);
   age    
----------
 90 years


Is there a reason for 1) being different in respect of the other queries?


Kind regards,
 Pietro Pugni

pgsql-bugs by date:

Previous
From: Pietro Pugni
Date:
Subject: Re: [BUGS] BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Next
From: Pedro Gimeno
Date:
Subject: [BUGS] Re: BUG #14632: Plus and minus operators inconsistency with leapyears and year intervals.