Presto SQL – Converting a date string to date format

Presto SQL – Converting a date string to date format

I figured it out. The below works in converting it to a 24 hr date format.

select date_parse(7/22/2016 6:05:04 PM,%m/%d/%Y %h:%i:%s %p)

See date_parse documentation in Presto.

You can also do something like this

date(cast(2016-03-22 15:19:34.0 as timestamp))

Presto SQL – Converting a date string to date format

Use: cast(date_parse(inv.date_created,%Y-%m-%d %h24:%i:%s) as date)

Input: String timestamp

Output: date format yyyy-mm-dd

Leave a Reply

Your email address will not be published. Required fields are marked *