Google 工作表查询返回不正确的日期

Google sheets query returning incorrect date

我有一个查询,我正在尝试提取接下来 14 天的事件和之前 14 天的事件

出于某种原因,我添加了很多过去或未来的日期

=QUERY(Sheet1!A2:H200,"select A,B,G where dateDiff(now(), G) <14 and G is not null")

ABC 1 15 Feb 2019 ABC 1 1 Nov 2018 DFG 1 11 Nov 2018 ABC 1 2 Nov 2018

接下来是前 14 天

=QUERY(Sheet1!A:G,"select A,B,G where dateDiff(now(), G) >14 and G is not null")

   ABC 1    20 Oct 2018
   ABC 1    20 Oct 2018

我的查询有问题

https://docs.google.com/spreadsheets/d/1WI-FS0XFGi09d2wO005S3kOV_L2s9eR3ILxST6I1nVU/edit?usp=sharing

当您使用小于 14 时,未来日期也包括在内,因为 datediff returns 是一个负数。因此,添加另一个条件以排除未来日期,例如:

=QUERY(A:C,"select A,B,C where dateDiff(now(), C) <14 and C<now() and C is not null")

如果您想使用 datediff 完成所有操作,那就是

=query(A:C,"select A,B,C where datediff(C,now())<14 and datediff(C,now())>0")

下两周的约会(十四晚或两周)和

=query(A:C,"select A,B,C where datediff(now(),C)<14 and datediff(now(),C)>0")

前两周。

您可能想要放置 <= 和 >=,具体取决于您是否要包括今天的日期和日期 14 天 before/after 今天。