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...
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'