Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Casting unix time to date in Presto

Tags:

presto

I have timestamps stored in time since epoch (ms) and I would like to query and display results using a date formatted like 'yyyy-mm-dd'.

like image 402
deltap Avatar asked Jun 07 '17 19:06

deltap


People also ask

How do I cast a timestamp to date in Presto?

You can convert timestamp to date with cast(col as date) or date(col) .

How do I change my epoch time to date on Presto?

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. Returns the UNIX timestamp unixtime as a timestamp.


1 Answers

cast(from_unixtime(unixtime) as date)

See https://prestodb.io/docs/current/functions/datetime.html for more datetime functions.

like image 105
Christina Foley Avatar answered Oct 14 '22 00:10

Christina Foley