How to cast String into Date in Bigquery with date format MM/DD/YYYY
Use the PARSE_DATE function to cast / convert a string column to DATE value. Check the below example for usage and syntax:
Example:
WITH `project.dataset.table` AS (\n SELECT '1/1/2020' date_as_string UNION ALL\n SELECT '12/31/2020'\n)\nSELECT PARSE_DATE('%m/%d/%Y', date_as_string) date_as_date\nFROM `project.dataset.table`\n
\n\nOutput:
\n\nRow date_as_date \n1 2020-01-01 \n2 2020-12-31 \n
victor
posted onEnjoy great content like this and a lot more !
Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds
Post Comment