Epoch from age is incorrect

From: Zhihong Zhang <zhihong(at)gmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Epoch from age is incorrect
Date: 2021-10-11 20:39:37
Message-ID: E756CE54-1946-4DC8-9F63-9BB54A07EF63@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Geoghegan 2021-10-11 21:33:23 Re: BUG #17212: pg_amcheck fails on checking temporary relations
Previous Message Mark Dilger 2021-10-11 20:20:26 Re: BUG #17212: pg_amcheck fails on checking temporary relations