Timothy Leavitt · Jul 20, 2022

Converting POSIX to ODBC timestamp in SQL

I'm getting wrapped around the axle with CAST and CONVERT and can't seem to find a way to do this (short of adding a stored procedure wrapping $zdt($zdth(posix,-2),3), which I'm refusing to do on principle, because there has to be some way to make this work).

Any ideas?

$ZV: Cache for UNIX (Red Hat Enterprise Linux for x86-64) 2017.2.2
0 99
Discussion (4)1
Log in or sign up to continue

On further investigation, it seems that what I need just isn't in the old version I'm running.

Is there a solution for latest?

Spent like half an hour on this puzzle with no results.

select 1672185599,CONVERT(TIMESTAMP,CAST(1000000 * 1672185599 + POWER(2,60) As POSIXTIME))

Quite intuitive. wink