title: How to group by hour in Google Bigquery
body: <p>My Google Bigquery table have date and time column. New data are posted in table every 10 minutes, so date field would have e.g. "2018-10-26" and time field "19:05:00". Next record would be like "2018-10-26" and "19:15:00" for date and time field. How to aggregate data for each day by one hour (24 records per day)?</p>
  
  <p>SQL request is sent from Google Sheets using Apps Script. Here is part of google bigquery.gs script: (<a href="https://github.com/gsuitedevs/apps-script-samples/blob/master/advanced/bigquery.gs" rel="noreferrer">complete script in GitHub</a>)</p>
  
  <pre><code>...
  var sheet = SpreadsheetApp.getActiveSheet();
  
  var sql = 'SELECT  date, time, SUM(col1) AS Col1, SUM(col2) AS Col2 GROUP BY 
  time, date ORDER BY time ASC';
  
  var queryResults; 
  
  // Inserts a Query Job
  try {
  var queryRequest = BigQuery.newQueryRequest();
  queryRequest.setQuery(sql).setTimeoutMs(100000);
  queryResults = BigQuery.Jobs.query(queryRequest, projectNumber);
  }
  ....
  </code></pre>