Skip to main content

Converting Epoch time in milliseconds to Time stamp with Milliseconds

  • February 8, 2016
  • 1 reply
  • 9 views

Sandeep2016

Hi,

 

We have an incoming data file containing field values as below. We believe this are EPOCH timestamp values in milliseconds. Can someoen please help convert these to standard time stamp values. Standard 'EXTRACT' function doesn't seem to work here.

 

1447103098937

1447103098765

1447103098915

1447103098980

 

Thanks

1 reply

sKwa
Forum|alt.badge.img+1
  • Participating Frequently
  • February 8, 2016

Hi!

 

Mathematically its not so simple.

An example gmtime source code: http://www.cise.ufl.edu/~cop4600/cgi-bin/lxr/http/source.cgi/lib/ansi/gmtime.c

 

 

TO_TIMESTAMP

Converts a string value or a UNIX/POSIX epoch value to a TIMESTAMP type.

 

 

dbadmin=> select to_timestamp(1447103098937 / 1000);
      to_timestamp       
-------------------------
 2015-11-09 16:04:58.937
(1 row)

Time: First fetch (1 row): 8.205 ms. All rows formatted: 8.272 ms
dbadmin=> select to_timestamp(1447103098980 / 1000);
      to_timestamp      
------------------------
 2015-11-09 16:04:58.98
(1 row)