Skip site navigation (1) Skip section navigation (2)

BUG #5470: EXTRACT(epoch from ...) missing last digit

From: "Randy Solomonson" <pgsqlbugs(at)solomonson(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5470: EXTRACT(epoch from ...) missing last digit
Date: 2010-05-24 16:48:07
Message-ID: 201005241648.o4OGm7LS019532@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      5470
Logged by:          Randy Solomonson
Email address:      pgsqlbugs(at)solomonson(dot)com
PostgreSQL version: 8.4.2
Operating system:   Red Hat 4.1.2-46 (64-bit)
Description:        EXTRACT(epoch from ...) missing last digit
Details: 

When converting from Timestamp with Time zone to seconds since epoch, the
last digit of the fraction of a second is missing.

Try the following query:
SELECT x,EXTRACT(epoch from x),EXTRACT(microseconds from x)/1000000
FROM (SELECT '2010-05-24 11:38:01.701845'::timestamp x)t

Here are the results:
             x              |    date_part     | ?column?
----------------------------+------------------+----------
 2010-05-24 11:38:01.701845 | 1274719081.70184 | 1.701845

Notice the date_part ends in 70184 and drops the sixth digit (a "5" in this
case).  Oddly enough, the last digit was also not rounded up.  However, it
is rounded up in some cases (eg .538505)

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2010-05-24 17:27:07
Subject: Re: BUG #5470: EXTRACT(epoch from ...) missing last digit
Previous:From: Tom MolesworthDate: 2010-05-24 15:22:31
Subject: Re: psql or pgbouncer bug?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group