timestamp - Convert unix epoch time to a date in Apache Derby -


is there function in apache derby can convert unix epoch time value (eg. 1453974057 ) date?

if have seconds since unix epoch, use:

select     {fn timestampadd(sql_tsi_second, 1453974057, timestamp('1970-01-01-00.00.00.000000')) } dt sysibm.sysdummy1 

just replace "sysibm.sysdummy1" original table, , replace 1453974057 value.

when dealing milliseconds gets bit more complicated because can't use timestampadd directly (you sql state 22003: resulting value outside range data type integer.)

if have milliseconds since unix epoch, use:

select     --the following block converts milliseconds since linux epoch timestamp     { fn timestampadd(         sql_tsi_frac_second,         (             --add millisecond component             1453974057235 - { fn timestampdiff(                 sql_tsi_second,                 timestamp('1970-01-01-00.00.00.000000'),                 { fn timestampadd(sql_tsi_second, 1453974057235/1000, timestamp('1970-01-01-00.00.00.000000')) }             )} * 1000          ) * 1000000,          { fn timestampadd(sql_tsi_second, 1453974057235/1000, timestamp('1970-01-01-00.00.00.000000')) }     )} final_dt sysibm.sysdummy1 

just replace 3 instances of 1453974057235 value.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -