Epoch from age is incorrect - Mailing list pgsql-bugs

From Zhihong Zhang
Subject Epoch from age is incorrect
Date
Msg-id E756CE54-1946-4DC8-9F63-9BB54A07EF63@gmail.com
Whole thread Raw
Responses Re: Epoch from age is incorrect  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Epoch from age is incorrect  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The epoch from following statement is incorrect,

test_db=# select extract(epoch from age(TIMESTAMP '2013-02-18 06:15:15'));
 date_part 
-----------
 272396685
(1 row)


The correct value should be

test_db=# select (extract(epoch from now()) - extract(epoch from TIMESTAMP '2013-02-18 06:15:15'));
     ?column?     
------------------
 272816228.311208
(1 row)

They are several days apart. Maybe leap years are not counted properly?

Postgresql version:

PostgreSQL 11.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 

Let me know if you need more information. Thanks!

Zhihong

pgsql-bugs by date:

Previous
From: Vik Fearing
Date:
Subject: Re: BUG #17220: ALTER INDEX ALTER COLUMN SET (..) with an optionless opclass makes index and table unusable
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #17221: Data sending resume