Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ma3HM-0005e2-WB for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Oct 2021 21:56:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ma3HL-0006OZ-O9 for pgsql-bugs@arkaria.postgresql.org; Mon, 11 Oct 2021 21:56:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ma3HL-0006OR-HT for pgsql-bugs@lists.postgresql.org; Mon, 11 Oct 2021 21:56:15 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ma3HJ-0006JE-7O for pgsql-bugs@lists.postgresql.org; Mon, 11 Oct 2021 21:56:14 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1ma3HI-00061G-75; Mon, 11 Oct 2021 17:56:12 -0400 Date: Mon, 11 Oct 2021 17:56:12 -0400 From: Bruce Momjian To: "David G. Johnston" Cc: Zhihong Zhang , pgsql-bugs Subject: Re: Epoch from age is incorrect Message-ID: <20211011215612.GE643@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Oct 11, 2021 at 02:52:59PM -0700, David G. Johnston wrote: > On Monday, October 11, 2021, Zhihong Zhang 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 https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.