【问题标题】:SharePoint CAML ORSharePoint CAML 或
【发布时间】:2018-07-02 15:46:35
【问题描述】:

如何将此 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>

【问题讨论】:

    标签: sharepoint caml


    【解决方案1】:

    使用下面的 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

    【讨论】:

    • 我在看到这个之前就想到了这个,我的 CAML 看起来就像这样。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-03
    • 2010-12-31
    • 1970-01-01
    相关资源
    最近更新 更多