BigQuery - how to compare a “date” column (using legacy SQL)?

后端 未结 2 564
别跟我提以往
别跟我提以往 2021-02-05 12:14

I have a BigQuery table with a column Date which is a date type. I am trying to run this query:

SELECT * FROM dataset.table_name WHERE          


        
相关标签:
2条回答
  • 2021-02-05 12:36

    Try below

    WHERE DATE(Date) = "2016-07-11"
    

    My additional recommendation would be to not to use reserved words as column's name, I think if your column was named properly - your original WHERE clause would worked perfectly and you would not need to use workaround with DATE()=""

    0 讨论(0)
  • 2021-02-05 12:38

    This solution wasn't working for me:

    DATE(Date) = "2016-07-11"
    

    Instead, I had to use:

    Date = TIMESTAMP("2016-07-11")
    
    0 讨论(0)
提交回复
热议问题