Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 597
Jeanette Kim Avatar asked Sep 18 '25 06:09

Jeanette Kim


1 Answers

You can use from_unixtime():

presto> select from_unixtime(1556895150);
          _col0
-------------------------
 2019-05-03 07:52:30.000
(1 row)
like image 167
Martin Traverso Avatar answered Sep 20 '25 19:09

Martin Traverso