日期查询与当前日期在两个date_time列之间 [英] Date query with the current date between two date_time columns
问题描述
我想用当前日期进行查询,仅在当前日期位于开始和结束日期之间的地图上显示KML行。
我尝试使用以下代码创建一个日期的字符串格式:
var time_date = new Date();
var day = time_date.getDate();
var month = time_date.getMonth()+ 1;
var year = time_date.getFullYear();
var date =(year +。+ month +。+ day);
要在地图上显示KML行,我尝试使用以下代码:
layer = new google.maps.FusionTablesLayer({
map:map,
heatmap:{enabled:false}
查询:{
select:col2,
from:1mOMP1seJq4FdiNTugsfylZaJc8sKcSlfJKUuTJjv,
其中:'Startdatum'< = date AND'Einddatum'> = date
},
选项:{
styleId:2,
templateId:2
}
});
不幸的是,地图显示了所有KMS行,而不管其中一列是什么日期。 p>
我做错了什么?
-
其中
-clause是错误的,它必须是其中:Startdatum< ='+ date +'和Einddatum> ='+ date +'
-
date
-format似乎是错误的。虽然在文档中定义了使用的格式yyyy.MM.dd
,但它不起作用。格式yyyy-MM-dd
目前适用于我(但在文档中没有定义)。var date =(year + - + month + - + day);
(如果日期和月份小于10,则不符合模式,但是似乎不是一个问题)
除此之外:当您修复这两个提到的部分时,它目前工作(对我而言),但是我已经在几个小时前试过了,结果不稳定。
I have a fusion table with two date_time columns. The fist one is the start date (Startdatum) and in the other column is the end date (Einddatum).
I want to do a query with the current date, and only show the KML-lines on a map where the current date lies between the start and end date.
I tried to use the code below to create a string with a date format:
var time_date = new Date();
var day = time_date.getDate();
var month = time_date.getMonth()+1;
var year = time_date.getFullYear();
var date = (year+"."+month+"."+day);
To show the KML-lines on the map I tried to use the following code:
layer = new google.maps.FusionTablesLayer({
map: map,
heatmap: { enabled: false },
query: {
select: "col2",
from: "1mOMP1seJq4FdiNTugsfylZaJc8sKcSlfJKUuTJjv",
where: "'Startdatum' <= date AND 'Einddatum' >= date"
},
options: {
styleId: 2,
templateId: 2
}
});
Unfortunatly the map shows all the KMS-lines regardless what date is in one of the columns.
What am I doing wrong?
the
where
-clause is wrong, it has to bewhere: "Startdatum <= '"+date+"' AND Einddatum >= '"+date+"'"
the
date
-format seems to be wrong. Although the used formatyyyy.MM.dd
is defined in the documentation, it doesn't work. The formatyyyy-MM-dd
currently works for me(but it's not defined in the documentation).var date = (year+"-"+month+"-"+day);
(in case that day and month be less than 10 they wouldn't match the pattern, but that doesn't seem to be an issue)
Beyond that: when you fix these 2 mentioned parts it currently works(for me), but I've tried it a couple of hours ago and got unstable results.
这篇关于日期查询与当前日期在两个date_time列之间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!