How to parse and convert string to date in Bigquery

The string value in this column looks like this "20180902". It needs to be converted to a date value in BigQuery


Below example shows that if value is really "20180902" as you state it should work

WITH `project.dataset.table` AS (
  SELECT '20180902' timeStamp   
  PARSE_DATE('%Y%m%d', timeStamp    ) AS date    
FROM `project.dataset.table`


Row   timeStamp   date   
1     20180902    2018-09-02     


posted on 01 Feb 21

Enjoy 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