Can't Extract Date from Timestamp in BigQuery
<p>I'm trying to get all rows associated with a particular entity ID over the last week. Each row has a timestamp. I'd like to group those entities by day, by extracting the date from the datetime timestamp, but when I try, I get</p>

<blockquote>
  <p>Error: (L6:28): expression STRFTIME_UTC_USEC([data_timestamp], '%Y-%m-%d') in GROUP BY is invalid</p>
</blockquote>

<p>from bigquery. It appears as though something is wrong with the DATE() function. </p>

<p>Here is the full query I am running:</p>

<pre><code>SELECT Count(*) FROM [myproj:mydataset.mytable] 
WHERE 
    bool_property=False 
AND 
    entity_id=5667423172689920 
AND
    DATEDIFF(CURRENT_DATE(), data_timestamp) &lt;= 7
GROUP BY DATE(data_timestamp)
</code></pre>

<p>Looking at the data, it would appear that the quality, here called 'data_timestamp' is in fact a proper timestamp; I really don't understand why the DATE() function would be failing.  </p>

<p>Any help or tips? Thanks!</p>