Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Pietro Pugni <pietro(dot)pugni(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Date: 2017-04-26 23:25:53
Message-ID: CAKFQuwarKmdOQ09k5vM2imGHBVmeriPa8i4+Yqz7gw8u8PCOOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Apr 26, 2017 at 4:18 PM, David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Wed, Apr 26, 2017 at 4:01 PM, Pietro Pugni <pietro(dot)pugni(at)gmail(dot)com>
> wrote:
>
>>
>> How?
>>
>>
>> Probably considering leap dates as singularities and threat them by
>> subtracting 1 day.
>> For example, a possible workaround to properly calculate the interval
>> between 1922-02-28 and 1922-02-29 is the following:
>>
>> SELECT age('1922-02-28'::date, '1912-02-29'::date - '1 day'::interval)
>> age
>> ----------
>> 10 years
>>
>
> At first glance I would consider this a worthwhile path to explore; and it
> meshes well with the comment I made above (before reading this) about the
> functions are either ignoring or mapping the 29th to the 28th. Subtracting
> 1 day to leap-year dates effective does both. I'm sure there are other
> interactions involved here but if for someone willing to do the work this
> approach seems to have some merit.
>
>
​And given that simple of a definition writing your own age function that
checks for the 29th and makes the adjustment would be trivial...so if
that's the extent I'm not sure PostgreSQL would want to change the
definition of the included age function and risk backward compatibility
issues.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Pietro Pugni 2017-04-26 23:48:41 Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.
Previous Message David G. Johnston 2017-04-26 23:18:52 Re: BUG #14632: Plus and minus operators inconsistency with leap years and year intervals.