Presto SQL - Converting a date string to date format Presto SQL - Converting a date string to date format sql sql

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.


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

Input: String timestamp

Output: date format 'yyyy-mm-dd'


You can also do something like this

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