Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert unix timestamp to H2 timestamp

Tags:

timestamp

h2

How do I convert unix timestamp value like 1348560343598 to H2 Timestamp?

One of my tables contains these unix timestamps in a BIGINT(19) column and I need to convert them to a column of type TIMESTAMP.

like image 974
vertti Avatar asked Apr 15 '13 09:04

vertti


1 Answers

Ok, using the following formula works:

select DATEADD('SECOND', 1348560343, DATE '1970-01-01')

Just remember to divide the timestamp with 1000. Using 'MILLISECOND' doesn't work, you will get Numeric value out of range.

like image 72
vertti Avatar answered Nov 03 '22 06:11

vertti