I am using CAML query to retrieve events in a range of dates. Currently, it retrieves nothing eventhough there are events in the range of dates
Is there something wrong with my CAML Query? It can retrieve all events when i take away the query line
Here is my code:
DateTime todayDate = DateTime.Now.Date;
DateTime tomorrowDate = todayDate.AddDays(1);
tomorrowDate = tomorrowDate.AddSeconds(-1);
query.Query = "<Query><Where><And><Geq><FieldRef Name=\"StartTime\" /><value IncludeTimeValue=\"true\" type=\"DateTime\">" + todayDate + "</value></Geq><leq><FieldRef Name=\"EndDate\"/><Value IncludeTimeValue=\"true\" Type=\"DateTime\">" + tomorrowDate + "</value></leq></And></Where><Query>";
query.ExpandRecurrence = true;
query.ViewFields = @"<FieldRef Name='Title' /><FieldRef Name='EventDate' /><FieldRef Name='EndDate' />";
SPListItemCollection items = list.GetItems(query);
foreach (SPListItem listItem in items)
{
retrievedData.Add(listItem["Title"].ToString());
retrievedData.Add(listItem["EventDate"].ToString());
retrievedData.Add(listItem["EndDate"].ToString());
}