From: Pietro Pugni <pietro.pugni@gmail.com>
To: Pantelis Theodosiou <ypercube@gmail.com>
Cc: Marko Tiikkaja <marko@joh.to>
Cc: David G. Johnston <david.g.johnston@gmail.com>
Cc: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Pedro Gimeno <pgsql-004@personal.formauri.es>
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Date: Fri, 28 Apr 2017 12:46:38 +0200
Message-ID: <FDFDA51E-CE35-4C7A-B4D8-3EB6BDF88153@gmail.com> (raw)
In-Reply-To: <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com>
References: <20170426182322.24371.95224@wrigleys.postgresql.org>
<CAKFQuwZ+PXKFrQ+LqOOorfva9nMesie0WQpe_hJTdkMn7vCZAw@mail.gmail.com>
<5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com>
<CAKFQuwZDo-CwNiqJ_v64HkKntggFmz1sN82n+FLy99qfez9-3g@mail.gmail.com>
<AA4AA8B1-AD27-458F-9941-6E5B5F56EACA@gmail.com>
<CAL9smLD5ARjoWon=YgJCXKD-Dc9cCPXOhNRQYxu_J-4ivPeuPw@mail.gmail.com>
<6CEF6FC2-6081-48CC-B534-055594B3851A@gmail.com>
<CAE3TBxzz-rSEsctew3HeKQQbQcsXErTKCgkXfEUosdsFtGCEbA@mail.gmail.com>
<07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: pietro.pugni@gmail.com, ypercube@gmail.com, marko@joh.to, david.g.johnston@gmail.com, tgl@sss.pgh.pa.us, pgsql-004@personal.formauri.es
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
In-Reply-To: <FDFDA51E-CE35-4C7A-B4D8-3EB6BDF88153@gmail.com>
References: <20170426182322.24371.95224@wrigleys.postgresql.org> <CAKFQuwZ+PXKFrQ+LqOOorfva9nMesie0WQpe_hJTdkMn7vCZAw@mail.gmail.com> <5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com> <CAKFQuwZDo-CwNiqJ_v64HkKntggFmz1sN82n+FLy99qfez9-3g@mail.gmail.com> <AA4AA8B1-AD27-458F-9941-6E5B5F56EACA@gmail.com> <CAL9smLD5ARjoWon=YgJCXKD-Dc9cCPXOhNRQYxu_J-4ivPeuPw@mail.gmail.com> <6CEF6FC2-6081-48CC-B534-055594B3851A@gmail.com> <CAE3TBxzz-rSEsctew3HeKQQbQcsXErTKCgkXfEUosdsFtGCEbA@mail.gmail.com> <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com> <FDFDA51E-CE35-4C7A-B4D8-3EB6BDF88153@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox