Reputation: 79
i have an epoch date time field which is stored as string in database table. i need to cast this to timestamp in impala sql. I am using the below format and not working. cast(unix_timestamp(execn_start_ts, "yyyy-MM-dd;HH:mm:ss") as timestamp) where execn_start_ts is the field from my table with unix/epoch time stored as string.
Upvotes: 2
Views: 5470
Reputation: 41
The approach below keeps the ms information if your epoch time ms provides it.
select CAST(CAST(ms_epoch_time as BIGINT) / 1000 AS TIMESTAMP)
as new_timestamp
from db.some_tabl_name
--ms_epoch_time - 1608249590791
--new_timestamp - 2020-12-17 23:59:50.790999889
Upvotes: 2