I would like to search items between two dates in a DocumentLibrary. The query find the files at root just right. However the query doesn't seem to be considering files in folders.
Here is my attempt :
var listToQuery = web.Lists["Pages"];
var formatedStartDate = SPUtility.CreateISO8601DateTimeFromSystemDateTime(Convert.ToDateTime(startDate));
var formatedEndDate = SPUtility.CreateISO8601DateTimeFromSystemDateTime(Convert.ToDateTime(endDate));
var query = new SPQuery
{
Query =
@"<Where><And><Geq><FieldRef Name='SAG_PublicationDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" +
formatedStartDate +
"</Value></Geq><Leq><FieldRef Name='SAG_PublicationDate' /><Value IncludeTimeValue='TRUE' Type='DateTime'>" +
formatedEndDate + "</Value></Leq></And></Where>",
ViewAttributes = "scope=\"RecursiveAll\"",
Folder = listToQuery.RootFolder
};
var result = listToQuery.GetItems(query).Count;
Am I missing something ? Why does the "RecursiveAll" doesn't seem to do anything ?
Folder = listToQuery.RootFolder
line and try