围绕 Google 张移动日历事件

Moving Calendar Events around Google Sheets

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

数据是从 Google 日历中提取的,并放入一个名为 Under The Hood 的隐藏 sheet 中。然后,我使用以下查询尝试提取 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)

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

解决方案

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

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

(显式插入括号)

这意味着只要检查 M 包含 'P/U'.

,它就会 return 为真

您应该以一种可以检查的方式来制定您的逻辑语句:

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

要做到这一点,只需按照文档的建议将 M 列上的逻辑语句包装在括号内即可:

You can join multiple conditions using the logical operators and, or, and not. Parentheses can be used to define explicit precedence.

=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

你的公式应该是:

=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)