Re: Epoch from age is incorrect - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: Epoch from age is incorrect
Date
Msg-id 20211011215612.GE643@momjian.us
Whole thread Raw
In response to Re: Epoch from age is incorrect  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
On Mon, Oct 11, 2021 at 02:52:59PM -0700, David G. Johnston wrote:
> On Monday, October 11, 2021, Zhihong Zhang <zhihong@gmail.com> wrote:
> 
> 
>     They are several days apart. Maybe leap years are not counted properly?
> 
> 
> That is related.  Intervals supply integer years, months, and days (for
> example).  Given an integer month (or year) value there is no way to accurately
> compute the number of days involved (or any subfield of day) since you lack
> knowledge of which months (years) they are (generally).  So extracting an epoch
> from an interval is an inherently unwise thing to do.  Having done it,
> comparing its result to a timestamp epoch computation is meaningless.  If you
> can do the later then just do it as it will provide the expected answer while
> the interval epoch is inherently problematic.

Yes.  Also, this blog has more details:

    https://momjian.us/main/blogs/pgblog/2020.html#August_3_2020

-- 
  Bruce Momjian  <bruce@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

  If only the physical world exists, free will is an illusion.




pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Epoch from age is incorrect
Next
From: Tom Lane
Date:
Subject: Re: Epoch from age is incorrect