SharePoint CAML 或

SharePoint CAML OR

如何将此 SQL 写成 CAML?

CurrentDate = Now()
StartDate = '1-1-2018 12:00 AM'
EndDate = '1-1-2018 11:59 PM'

SELECT * FROM Calendar as c
WHERE (c.EventDate <= CurrentDate AND c.EndDate >= CurrentDate)
    OR (c.EventDate <= StartDate AND c.EndDate <= EndDate)

This link 看起来不错,但无法满足我的要求。

这是我的 CAML,但它不起作用,我收到未定义的错误:

<View>
  <Query>
    <Where>
      <Or>
        <Leq><FieldRef Name='EventDate' /><Value StorageTZ='TRUE' IncludeTimeValue="FALSE" Type="DateTime">2018-07-01T00:00:00-0400</Value></Geq>
        <Geq><FieldRef Name='EndDate' /><Value StorageTZ='TRUE' IncludeTimeValue="FALSE" Type="DateTime">2018-07-01T00:00:00-0400</Value></Leq>
          <Or>
              <Leq><FieldRef Name='EventDate' /><Value StorageTZ='TRUE' IncludeTimeValue="FALSE" Type="DateTime">2018-07-01T00:00:00-0400</Value></Leq>
              <Geq><FieldRef Name='EndDate' /><Value StorageTZ='TRUE' IncludeTimeValue="FALSE" Type="DateTime">2018-07-01T23:59:59-0400</Value></Geq>
          </Or>
      </Or>
    </Where>
   </Query>
</View>

使用下面的 CAML 查询。

<Query>
<Where>
        <Or>
            <And>
                <Leq>
                    <FieldRef Name="EventDate"/>
                    <Value IncludeTimeValue='TRUE' Type='DateTime'>2018-07-01T00:00:00Z</Value>
                </Leq>
                <Geq>
                    <FieldRef Name="EndDate"/>
                    <Value IncludeTimeValue='TRUE' Type='DateTime'>2018-07-01T00:00:00Z</Value>
                </Geq>
            </And>
            <And>
                <Leq>
                    <FieldRef Name="EventDate"/>
                    <Value IncludeTimeValue='TRUE' Type='DateTime'>2018-07-01T00:00:00Z</Value>
                </Leq>
                <Leq>
                    <FieldRef Name="EndDate"/>
                    <Value IncludeTimeValue='TRUE' Type='DateTime'>2018-07-01T23:59:59Z</Value>
                </Leq>
            </And>          
        </Or>   
</Where>
</Query>

这里有一个 SharePoint CAML 查询设计器工具供您参考。 https://github.com/konradsikorski/smartCAML