如何在所选列中只有空值的情况下使用toDate查询护目镜电子表格 [英] How to query a Goggle Spreadsheet using toDate when there are only empty values in the selected column
问题描述
查询:select * where toDate(A)> =>我想查询使用toDate的列只包含空值,查询失败则不执行。 '2016-01-01'。
https://docs.google.com/spreadsheets/d/19olM1pEF5qQvvKhwSH3d_X4w2DVfOWDwDtZKNFlMY3w/edit#gid=0
我应该怎么做?请帮忙。
在此先感谢。
$ b 注意:即使给定列中有单个条目,查询也能正常工作。
<不知道
toDate
... 但是要将值转换为日期,只需将该值加上date一词即可。
即 - > date'2016-01-01'
请参阅以下示例...
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());返回; } 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,{});}
<< code<< ; script>< / div>< / code&
The column i want to query using toDate contains only empty values, the query fails it does not execute.
Query: select * where toDate(A) >= '2016-01-01'.
https://docs.google.com/spreadsheets/d/19olM1pEF5qQvvKhwSH3d_X4w2DVfOWDwDtZKNFlMY3w/edit#gid=0
What should i do? Please help. Thanks in Advance.
Note: The query works fine even if there is a single entry in the given column.
Don't know about toDate
...
But to convert a value to a date, simply prefix the value with the word 'date'.
i.e. --> 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查询护目镜电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!