Amazon Athena Convert String to Date

Data_101 picture Data_101 · Jan 8, 2018 · Viewed 25.3k times · Source

I am looking to convert the following string: mmm-dd-yyyy to a date: yyyy-mm-dd

e.g

Nov-06-2015 to 2015-11-06

within Amazon Athena

Answer

Blu3 picture Blu3 · Apr 5, 2018

I would do date_parse. Adjust your regex accordingly.

select date_parse('Nov-06-2015','%b-%d-%Y')

2015-11-06 00:00:00.000

refd:https://prestodb.io/docs/current/functions/datetime.html