STRING to DATE in BIGQUERY

前端 未结 2 1837
慢半拍i
慢半拍i 2020-12-06 05:03

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)
         


        
相关标签:
2条回答
  • 2020-12-06 05:26

    This solution can work

    SELECT    CAST(
                CONCAT(
                  SUBSTR(DT_DOCUMENTO, 0 , 4), 
                  '-' ,
                  SUBSTR(DT_DOCUMENTO, 5 , 2), 
                  '-' , 
                  SUBSTR(DT_DOCUMENTO, 7 , 2) 
                ) AS DATE
              ) AS FORMAT_DATE
    
    0 讨论(0)
  • 2020-12-06 05:30

    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

    0 讨论(0)
提交回复
热议问题