'How can I convert an integer representing EPOCH time to a timestamp in Athena (Presto)?
I have a table where the datetime is stored as varchar but represents the EPOCH time (e.g. 1556895150). How can I get that value to be recognized as a timestamp in Athena / using Presto? something like a dateadd function would work but Athena doesn't have dateadd (I envisioned something like dateadd('second',expressoin,'1970-01-01 00:00:00'. A simple CAST(expressoin as type) does not work here because EPOCH isn't a recognized datetime data type.
Solution 1:[1]
You can use from_unixtime()
:
presto> select from_unixtime(1556895150);
_col0
-------------------------
2019-05-03 07:52:30.000
(1 row)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |