I need to get all events in a calendar, including series (with expanded recurrence), then I saw that I'm able to get this data using the Lists.asmx web service and CAML query from this link: https://gist.github.com/MartinBodocky/7984439. However, it returns all events, including past events, and uses the deprecated API.

I want to know if I can achieve the same result using SharePoint 2013 CSOM and if not, is it possible to add a filter to the CAML query bellow to get only events in the future?

<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> <soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<FieldRef Name="EventDate" />
<FieldRef Name="EndDate" />
<FieldRef Name="RecurrenceID" />
<Value Type='DateTime'><Year/></Value>

1 Answer 1


As far as I know, you can achieve it only via the Lists web service, if you have to access it from the client side. It means, no support in CSOM or OData / REST, see this article.

You can define a variable for the current date as:

var today = DateTime.UtcNow.Date;
var todayAsString = today.ToString("yyyy-MM-dd");

Then you SHOULD be able to use its value in your query to restrict the result for the events in the future, if you use a double condition in the query part of your request:

string.Format("<Query><Where><And><Gt><FieldRef Name='EventDate' /><Value Type='DateTime'>{0}</Value></Gt><Eq><DateRangesOverlap><FieldRef Name='EventDate' /><FieldRef Name='EndDate' /><FieldRef Name='RecurrenceID' /><Value Type='DateTime'><Year/></Value></DateRangesOverlap></And></Where><Query>", todayAsString);

But based on my experience, this kind of query won't work. If you include another DateTime-based condition in the query beyond DateRangesOverlap, the recurring events won't be expanded again. Just another 'kind' surprise from SharePoint. The expanding of recurring events seems to work only if you use DateRangesOverlap, and you use only this kind of DateTime-based condition in your query (but no other condition like <Eq> or <Gt> combined with a DateTime field).

You CAN however combine DateRangesOverlap with other kind of conditions (like <Eq> or <Gt>), as long as they are related to other field types, like Number or Text.

It means you should page through your calendar (by setting the CalendarDate QueryOption) to aggregate the calendar events, and if you are in the same year (month /week) as your start date, you should add an extra condition in your code (I mean C# or JavaScript, not in CAML!) to compare the dates. Really cumbersome.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.