How do I convert Unix Epoch time to a date or something more human readable with SQL?

Many times the Unix Epoch Time gets stored in the database. But this is not very human readable and conversion is required for reports and dashboards. 

Example of Unix Epoch Time: 

1529853245

Presto provides many date time functions to help with conversion. 

In case of a Unix Epoch Time, the from_unixtime function can be used to convert the Epoch time. 

This function returns a timestamp. 

from_unixtime(unixtime) → timestamp
Returns the UNIX timestamp unixtime as a timestamp.


After converting the Unix Epoch time to a timestamp, you can cast it into other formats as needed such as extracting just the date. Examples follow below. 


Examples: 

Query

select from_unixtime(1529853245) as timestamp;

Result

timestamp

2018-06-24 15:14:05.000

Query

select cast(from_unixtime(1529853245) as date) as date;

Result

date

2018-06-24
More examples and information can be found here: https://ahana.io/answers/how-to-convert-date-string-to-date-format-in-presto/