From: | Pietro Pugni <pietro(dot)pugni(at)gmail(dot)com> |
---|---|
To: | Pantelis Theodosiou <ypercube(at)gmail(dot)com> |
Cc: | Marko Tiikkaja <marko(at)joh(dot)to>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Pedro Gimeno <pgsql-004(at)personal(dot)formauri(dot)es> |
Subject: | Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. |
Date: | 2017-04-28 10:46:38 |
Message-ID: | FDFDA51E-CE35-4C7A-B4D8-3EB6BDF88153@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Pedro Gimeno | 2017-04-28 10:46:48 | Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. |
Previous Message | Pietro Pugni | 2017-04-28 09:04:01 | Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. |