Hi Guys I have this situation:
A timer job queries a list and gets items from it. The 2 queries are:
<Where>
<And>
<And>
<Leq>
<FieldRef Name="To" />
<Value Type="DateTime">[Today+5Day(s)]</Value>
</Leq>
<Gt>
<FieldRef Name="To" />
<Value Type="DateTime">[Today+0Day(s)]</Value>
</Gt>
</And>
<BeginsWith>
<FieldRef Name="ContentTypeId"/>
<Value Type="ContentTypeId">0x010050E924B6CB83F348AFD03D6A6A639920</Value>
</BeginsWith>
</And>
</Where>
And
<Where>
<And>
<Geq>
<FieldRef Name="Next_x0020_Oil_x0020_Change_x002" />
<Value Type="DateTime">[Today+0Day(s)]</Value>
</Geq>
<Leq>
<FieldRef Name="Next_x0020_Oil_x0020_Change_x002" />
<Value Type="DateTime">[Today+5Day(s)]</Value>
</Leq>
</And>
</Where>
Both queries are generated with the U2U Caml Query Builder work fine and return the items I need.
The Problem:
When I added code to use the queries the first returns 0 rows(shouldn't be 0), and the second throws the SPException - One or more field types are not installed properly.
How come that both queries work just fine in the U2U tool?
Here is some of the code I use:
SPList techInfoList = web.GetList(site.Url + "/Lists/TechInfo");
SPQuery caml = new SPQuery();
caml.Query = ...
items = techInfoList.GetItems(caml);
As far as I know there are no problems with the field types and the exception does not give any useful information of the field that could be causing the problem.
I read that [Today] could cause problems so I tried <Today ...>
. Still the same.