我将如何将这个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>发布于 2018-07-02 07:46:35
使用下面的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
https://stackoverflow.com/questions/51126892
复制相似问题