I have a column with a timestamp. The converted column gives me a datetime value starting from the year 1975. That means I should concat() that value with '0' and convert it to the correct datetime.
I wrote something, and it shows me very close values, but not the same when I double-check it in browser.
Example:
select to_timestamp(
cast(
dt:double precision/1000 as bigint
)
) as ts, *
from (select col1, col2, concat(timestamp, '0') as dt
from table1
order by col1 desc) as foo
For example, with the initial timestamp 168665720100, after concat and to_timestamp I get 2023-06-13 14:53:21, when it should be 2023-06-13 11:53:21.
to_timestampgives you atimestamp with time zone, so probably thetimezoneparameter in your session is set to a time zone offset three hours from UTC. Which means that the result could correct, and all you have to do is appendAT TIME ZONE 'UTC'.