I have 3 dates inserted in my list and they are:
- 1/1/2014 7:00 PM daily
- 12/2/2013 7:00 PM weekly
- 12/26/2013 7:00 PM monthly
I want CAML query in such a way that my current DateTime is 1/2/2014 6:22 PM. I want all these records selected as they are fall into next hour and duration given.
Please can anybody suggest me how to write query for this?
CAML Query as following:
<Query>
<Where>
<Or>
<And>
<Eq>
<FieldRef Name='DeliveryFrequency' />
<Value Type='Choice'>Daily</Value>
</Eq>
<And>
<Geq>
<FieldRef Name='LastDeliveryTime' />
<Value Type='DateTime'>[Today-1Day(s)]</Value>
</Geq>
<And>
<Geq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now-1Day(s)]</Value>
</Geq>
<Leq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now+60Minute(s)]</Value>
</Leq>
</And>
</And>
</And>
<Or>
<And>
<Eq>
<FieldRef Name='DeliveryFrequency' />
<Value Type='Choice'>Weekly</Value>
</Eq>
<And>
<Eq>
<FieldRef Name='LastDeliveryTime' />
<Value Type='DateTime'>[Today-7Day(s)]</Value>
</Eq>
<And>
<Geq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now-7Day(s)]</Value>
</Geq>
<Leq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now-7Day(s)+60Minute(s)]</Value>
</Leq>
</And>
</And>
</And>
<And>
<Eq>
<FieldRef Name='DeliveryFrequency' />
<Value Type='Choice'>Monthly</Value>
</Eq>
<And>
<Eq>
<FieldRef Name='LastDeliveryTime' />
<Value Type='DateTime'>[Today-1Month(s)]</Value>
</Eq>
<And>
<Geq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now-1Month(s)]</Value>
</Geq>
<Leq>
<FieldRef Name='LastDeliveryTime' />
<Value IncludeTimeValue='TRUE' Type='DateTime'>[Now-1Month(s)+60Minute(s)]</Value>
</Leq>
</And>
</And>
</And>
</Or>
</Or>
This is my query works fine with CAML query builder but in SPQuery it does not return any record. I have tried by providing ViewAttributes to "RecursiveAll". What is wrong with given code?