STRING to DATE in BIGQUERY

Lucasaudati11 picture Lucasaudati11 · Jun 15, 2017 · Viewed 49.7k times · Source

I am struggling trying to do this with Google BigQuery:

I do have a column with dates in this following STRING format:

6/9/2017   (M/D/YYYY)

I am wondering how can I deal with this, trying to use then the DATE clause., in order to get the DATE format:

YYYY-MM-DD.

Thanks in advance.

Answer

Felipe Hoffa picture Felipe Hoffa · Jun 15, 2017

Easy one, with standard SQL:

#standardSQL
SELECT PARSE_DATE('%m/%d/%Y',  '6/22/2017')


2017-06-22  

https://cloud.google.com/bigquery/docs/reference/standard-sql/functions-and-operators#supported-format-elements-for-date