问题
I have a string that is a date and it is in M/D/YYYY ie:
1/1/2018
12/31/2018
I get an invalid date error ( it shows: '2/18/2018' as the invalid date)
Any ideas?
回答1:
Below is example for BigQuery Standard SQL
#standardSQL
WITH `project.dataset.table` AS (
SELECT '1/1/2018' date_as_string UNION ALL
SELECT '12/31/2018'
)
SELECT PARSE_DATE('%m/%d/%Y', date_as_string) date_as_date
FROM `project.dataset.table`
with output:
Row date_as_date
1 2018-01-01
2 2018-12-31
来源:https://stackoverflow.com/questions/49074680/cast-string-into-date-in-bigquery-when-date-is-in-the-following-format-m-d-yyyy