I have written following CAML query to Retrieve items which are due in 7 days, It doesn't seems to be working, Please let me know what I missed ?
string internalEndDate = web.Lists["List Name"].Fields["Next End date"].InternalName;
<Where>
<AND>
<Leq>
<FieldRef Name ='" + internalEndDate + "'/>
<Value Type ='DateTime'>" + System.DateTime.Now.AddDays(7) + "</Value>
</Leq>
</AND>
</Where>
<OrderBy>
<FieldRef Name='" + internalClosure + "' Ascending='False' />
</OrderBy>";
The above query does't seem to be working, Also how can I add along with this condition, the data has to be greater than or equal to today. Thanks!!
UPDATE : (As Per Sven Gillis advise, Worked !!)
string Iso8601DateTime = XmlConvert.ToString(DateTime.Now.AddDays(7), XmlDateTimeSerializationMode.Local);
string Iso8601Today = XmlConvert.ToString(DateTime.Now, XmlDateTimeSerializationMode.Local);
<Where>
<AND>
<Leq>
<FieldRef Name ='" + internalEndDate + "'/>
<Value Type ='DateTime' IncludeTimeValue='FALSE'>" + Iso8601DateTime + "</Value>
</Leq>
<Geq>
<FieldRef Name ='" + internalEndDate + "'/>
<Value Type ='DateTime' IncludeTimeValue='FALSE'>>" + Iso8601Today + "</Value>
</Geq>
</AND>
</Where>
<OrderBy>
<FieldRef Name='" + internalClosure + "' Ascending='False' />
</OrderBy>";
And used, tag to filter the date greater than today!!
Got It Worked !!