How to convert DD-MMM-YY to YYYY/MM/DD in Big Query SQL

Viewed 1033

I've one date format as DD-MMM-YY in one of my Big Query table as a STRING column (e.g 31-OCT-20). Now I need to convert the format to YYYY/MM/DD in Date format to insert data to another table (e.g 2020/10/31).

Please help with the required format for Google Big Query.

Thanks in advance.

2 Answers

It worked after trying a combination of PARSE_DATE and FORMAT_DATE:

SELECT FORMAT_DATE("%Y/%m/%d",PARSE_DATE('%d-%b-%y','31-OCT-20'))

Use PARSE_DATE:

SELECT PARSE_DATE('%d-%b-%y','31-OCT-20')
Related