当所选列中只有空值时,如何使用toDate查询Google Spreadsheet [英] How to query a Google Spreadsheet using toDate when there are only empty values in the selected column
本文介绍了当所选列中只有空值时,如何使用toDate查询Google Spreadsheet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要使用toDate查询的列仅包含空值,查询失败,它将不执行.
The column I want to query using toDate contains only empty values, the query fails it does not execute.
查询:选择* where toDate(A)> ='2016-01-01'.
Query: select * where toDate(A) >= '2016-01-01'.
https://docs.google.com/spreadsheets/d /19olM1pEF5qQvvKhwSH3d_X4w2DVfOWDwDtZKNFlMY3w/edit#gid = 0
我该怎么办?
注意:即使给定列中只有一个条目,查询也可以正常工作.
Note: The query works fine even if there is a single entry in the given column.
推荐答案
不知道toDate
...
但是要将值转换为日期,只需在值前加上单词"date"即可.
But to convert a value to a date, simply prefix the value with the word 'date'.
即-> date '2016-01-01'
请参阅以下示例...
See following example...
google.charts.load('current', {
callback: drawVisualization,
packages: ['table']
});
function drawVisualization() {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/19olM1pEF5qQvvKhwSH3d_X4w2DVfOWDwDtZKNFlMY3w/edit#gid=0'
);
query.setQuery("select * where A >= date '2016-01-01'");
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
var data = response.getDataTable();
if (data.getNumberOfRows() === 0) {
data.setColumnLabel(0, 'Date');
data.setColumnLabel(1, 'Goal');
data.addRow([null, 'Nothing found']);
}
var visualization = new google.visualization.Table(document.getElementById('table'));
visualization.draw(data, {});
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="table"></div>
这篇关于当所选列中只有空值时,如何使用toDate查询Google Spreadsheet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文