How to convert milliseconds or seconds into date format in Presto?

Milliseconds:
DATE_FORMAT(FROM_UNIXTIME(column_name /1000),'%Y-%m-%d')
Seconds:
DATE_FORMAT(FROM_UNIXTIME(column_name),'%Y-%m-%d')

Please note that '/1000' should be added when it converts milliseconds to human-readable format. 
We have the column "purchased_date_epoch" stored as numeric format. Let's say we want to convert the "purchased_date_epoch" column value "1442287036" to human-readable format. 


SELECT purchased_date_epoch FROM table                              
return: 144287036 
SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d %T)
return: 2015-09-15 03:17:16                                         
SELECT DATE_FORMAT(FROM_UNIXTIME(purchased_date_epoch),'%Y-%m-%d)   
return: 2015-09-15                                                  



Comments