在Google表格中移动日历事件

时间:2020-08-05 19:15:03

标签: google-sheets google-calendar-api google-sheets-formula google-sheets-query google-query-language

我订阅了一系列Google日历。在我完成大部分工作的主电子表格中,我有一个启动页面,我希望从每个日历中提取今天和明天的事件。

数据从Google日历中提取,并放入一个名为Under The Hood的隐藏表中。然后,我使用以下查询尝试拉出与A)相关和B)今天(或明天,两个不同的查询)相关的查询。

今天的活动

=QUERY('Under The Hood'!M4:O13, "select M, N where M contains 'P/U' or M contains 'D/O' and toDate(O) contains 'toDate(TODAY())'",0)

明天的活动

=QUERY('Under The Hood'!M4:O13, "select M, N where M contains 'P/U' or M contains 'D/O' and O contains date'" & TEXT(TODAY()+1,"yyyy-mm-dd")&"'",0)

这两个查询都为我提供了明天和后天发生的事件的部分列表。

2 个答案:

答案 0 :(得分:1)

解决方案

您现在的逻辑语句是这样:

M contains 'P/U' or (M contains 'D/O' and O contains date'" & TEXT(TODAY()+1,"yyyy-mm-dd")&"')

(插入显式括号)

这意味着只要检查M包含“ P / U”,它将返回true。

您应该以以下方式制定逻辑语句:

M = 'P/U' and O = 'date you want' or M = 'D/O' and O = 'date you want'

要执行此操作,只需按照文档建议将逻辑语句包装在括号内的M列上即可。

您可以使用逻辑运算符and或or and and来加入多个条件。括号可用于定义显式优先级。

=QUERY('Under The Hood'!M4:O13, "select M, N where (M contains 'P/U' or M contains 'D/O') and O contains date '"& TEXT(TODAY(), "yyyy-mm-dd")&"'",0)

参考

Query Language

答案 1 :(得分:1)

您的公式应为:

=QUERY('Under The Hood'!M4:O, 
 "select M,N 
  where M matches '.*P/U.*|.*D/O.*' 
    and O contains date '"&TEXT(TODAY()+1, "yyyy-mm-dd")&"'", 0)

enter image description here