How to Convert Timestamp to Date in Presto?

I like to convert my timestamp columns to date and time format. How should I write the query from presto? my timestamp is UTC time. Thank you very much

Timestamp format"1506929478589"
After query convert it looks like "2016-10-25 21:04:08.436"

2 Answers

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

You can use the date_format function (docs here: )

Here's an example:

date_format(charges.created, '%Y-%m') as rev_month

If for some reason you're comparing dates you don't need to do the conversion like that, you can do the following

where customers.created BETWEEN timestamp '2018-04-01 00:00:00.000' AND timestamp '2018-05-01 00:00:00.000' 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest