I have a SharePoint calendar list which has some recurring events i wanted a report of about last two years. Following is the code that i have written
SPQuery qryBookings = new SPQuery();
qryBookings.ViewFields = "<FieldRef Name='Title'/>" +
"<FieldRef Name='LinkedBID'/>" +
"<FieldRef Name='Hosted_x0020_By'/>" +
"<FieldRef Name='Author'/>" +
"<FieldRef Name='Editor'/>" +
"<FieldRef Name='ID'/>" +
"<FieldRef Name='EventDate'/>" +
"<FieldRef Name='Duration'/>" +
"<FieldRef Name='Room'/>" +
"<FieldRef Name='Place'/>" +
"<FieldRef Name='Linked_x0020_Id'/>" +
"<FieldRef Name='UID'/>" +
"<FieldRef Name='Is_x0020_Linked'/>" +
"<FieldRef Name='fRecurrence'/>" +
"<FieldRef Name='Internal_x0020_Meeting'/>" +
"<FieldRef Name='RecurrenceID' />" +
"<FieldRef Name='MasterSeriesItemID'/>" +
"<FieldRef Name='EventType'/>" +
"<FieldRef Name='Virtual_x0020_Room'/>" +
"<FieldRef Name='EndDate'/>" +
"<FieldRef Name='Changeit'/>";
qryBookings.Query = "<Where>" +
"<DateRangesOverlap><FieldRef Name='EventDate' />" +//<And>
"<FieldRef Name='EndDate' />" +
"<FieldRef Name='RecurrenceID' />" +
"<Value Type='DateTime'><Year/></Value></DateRangesOverlap></Where><GroupBy Collapse ='TRUE'><FieldRef Name='EventDate'></FieldRef></GroupBy>";//<Eq><FieldRef Name='ID' /><Value Type='Counter'>4</Value></Eq></And><Eq><FieldRef Name='Linked_x0020_Id' /><Value Type='Text'>96312753-ca76-466f-87d4-c0f2387c2390</Value></Eq></And>
qryBookings.ExpandRecurrence = true;
qryBookings.CalendarDate = DateTime.Now;
SPListItemCollection bk_collec = lstBookings.GetItems(qryBookings);
According to most of the blogs <Year/>
returns all the events in the year in which the qryBookings.CalendarDate = DateTime.Now;
falls.
Now today is 17th Sept 2014 and on testing i found that the results returned are from 17th Sept 2013 to 17th June 2015 which is different from what most of the blogs say. i.e. this
Can anyone explain me what exactly happens and also let me know if there is a way where i can request for events which are in the span of more than a year.
Thanks