Time

Started by Rob Kirkbrideabout 21 years ago2 messagesgeneral
Jump to latest
#1Rob Kirkbride
rob.kirkbride@thales-is.com

Hi,

I'm trying to fetch out the epoch value of a time, the data type is
'timestamp with time zone'. When I do select extract(epoch from time) it
returns a fractional part as well.
Am I doing this the correct way? Is the fractional part microseconds?

Thanks for any help,

Rob

#2Ragnar Hafstað
gnari@simnet.is
In reply to: Rob Kirkbride (#1)
Re: Time

On Mon, 2005-04-04 at 13:49 +0100, Rob Kirkbride wrote:

Hi,

I'm trying to fetch out the epoch value of a time, the data type is
'timestamp with time zone'. When I do select extract(epoch from time) it
returns a fractional part as well.
Am I doing this the correct way? Is the fractional part microseconds?

no, it is fractions of a second.

test=# select extract(epoch from '2005-04-04 14:00:00.000000
+00'::timestamptz);
date_part
------------
1112623200
(1 row)

test=# select extract(epoch from '2005-04-04 14:00:00.123400
+00'::timestamptz);
date_part
-----------------
1112623200.1234
(1 row)

the accuracy probably depends on your platform

gnari