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

From David G. Johnston
Subject Re: Epoch from age is incorrect
Date
Msg-id CAKFQuwb5tRgZs0K_2iAzYdQ3uYcxMJ+zLObpYmx05HDpSiLCiQ@mail.gmail.com
Whole thread Raw
In response to Epoch from age is incorrect  (Zhihong Zhang <zhihong@gmail.com>)
Responses Re: Epoch from age is incorrect  (Bruce Momjian <bruce@momjian.us>)
List pgsql-bugs
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.

David J.
 

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #17221: Data sending resume
Next
From: Bruce Momjian
Date:
Subject: Re: Epoch from age is incorrect