Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d43R1-0003kB-IB for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2017 10:47:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d43R0-0002iZ-UT for pgsql-bugs@arkaria.postgresql.org; Fri, 28 Apr 2017 10:47:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d43QJ-0001W3-9X for pgsql-bugs@postgresql.org; Fri, 28 Apr 2017 10:46:51 +0000 Received: from mail-wm0-x243.google.com ([2a00:1450:400c:c09::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1d43QB-0008TX-L4 for pgsql-bugs@postgresql.org; Fri, 28 Apr 2017 10:46:50 +0000 Received: by mail-wm0-x243.google.com with SMTP id u65so10109718wmu.3 for ; Fri, 28 Apr 2017 03:46:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=n5gLcaVrk/fCmBB5+cs+mGWcdPIKYmAjCwuLHd/hpeY=; b=siSoAycgf91oiHYuzGR2QH5lkgehu02X4NHQ1GEA/AWA32vWXabCNEF/l6Gwg6emOA VneaMpwodYZ8TAXh0UzxFmdEZm6ihaFXmoul0ovJAP4yHYtukgsdwCcz2ypJ7EKbt0y5 2DkHm70MoFzVaN4En07CRl5Po9UBks6jG88HWMJG0TuIVAF39aX5R65ReOd3uQbnq8YQ aNv4T32jAe4F0r2UQr7updzYAfPBKxHZ638ie6ixYN2FJ8ZYupmAyBcvXwveiUGC7xx7 hq0kBezOuQW3zbHbNiwAJvyfCMRLsmFDBa7xATwh1m13MdZXHH91MAwoEpkDlYXGgtSx 8Utg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=n5gLcaVrk/fCmBB5+cs+mGWcdPIKYmAjCwuLHd/hpeY=; b=Is+TfLnt6gyOKDgIgYJwq/ASBo6/rh2Xv63UwKWGdYgLthBZvR2fzMbe6f7ne1fqbH jzDdLxxUc200v1NtS6Jm+g37L3byyabvVxEPhKIpW7YFLJ2WFqLw+bNc8eJbVsq5cVFu P4lLcRhJriboE8YijkjJ2yNMi4dS9NDcwJ/AhfZOWP8EjMvRp+J+a4LZ0WglwBHcGX6c F74eROfTARbo2Q1HGqctZWMcJZoKiNQT3eQL/zS8tx5GNb/WoAPyVOJrufx7rgaqmf1A SDO2XQ1prQ1QSE9CzFBNGUmWmvVCBDaTlX9TeHT4+miFICe6ofuMa1uammJfjvk8MXmD 1oXA== X-Gm-Message-State: AN3rC/6F5rg5BQIzlc1WzAwM783IIM5sx1bDhb5iChGSCwRNDJxDg9J6 miWldmWEcdeM/w== X-Received: by 10.28.17.21 with SMTP id 21mr5693792wmr.83.1493376401502; Fri, 28 Apr 2017 03:46:41 -0700 (PDT) Received: from [192.168.2.5] (2-230-140-245.ip202.fastwebnet.it. [2.230.140.245]) by smtp.gmail.com with ESMTPSA id 92sm4563207wra.0.2017.04.28.03.46.39 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Apr 2017 03:46:40 -0700 (PDT) Content-Type: multipart/alternative; boundary="Apple-Mail=_A8A1506D-4EB3-40B2-BBAC-4D413CE914E4" Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals. From: Pietro Pugni In-Reply-To: <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com> Date: Fri, 28 Apr 2017 12:46:38 +0200 Cc: Marko Tiikkaja , "David G. Johnston" , "pgsql-bugs@postgresql.org" , Tom Lane , Pedro Gimeno Message-Id: References: <20170426182322.24371.95224@wrigleys.postgresql.org> <5752C491-B0EC-4D1E-AF97-5E1C8C793A8A@gmail.com> <6CEF6FC2-6081-48CC-B534-055594B3851A@gmail.com> <07CA08CB-78FB-42F6-832F-F9F7B838C1A6@gmail.com> To: Pantelis Theodosiou X-Mailer: Apple Mail (2.3124) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --Apple-Mail=_A8A1506D-4EB3-40B2-BBAC-4D413CE914E4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 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 =20 ----------------------------------- 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 =20 ---------- 90 years 3) select age('2007-04-01'::timestamp without time zone, = '1917-04-01'::date); age =20 ---------- 90 years 4) select age('2007-04-01'::date, '1917-04-01'::timestamp without time = zone); age =20 ---------- 90 years I don=E2=80=99t 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 =20 ---------- 90 years 6) select age('2007-04-01'::date, '1917-04-01'::timestamp); age =20 ---------- 90 years 7) select age('2007-04-01'::timestamp, '1917-04-01'::date); age =20 ---------- 90 years Is there a reason for 1) being different in respect of the other = queries? Kind regards, Pietro Pugni --Apple-Mail=_A8A1506D-4EB3-40B2-BBAC-4D413CE914E4 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
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=E2=80=99t 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

= --Apple-Mail=_A8A1506D-4EB3-40B2-BBAC-4D413CE914E4--