I used DateRangesOverlap for fetching calendar events with recurring set to TRUE.

Below is the code :

SPQuery query = new SPQuery();
DateTime startDate = new DateTime(2009, 2, 1);
query.ExpandRecurrence = true;
query.CalendarDate = startDate;
query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Now /></Value></DateRangesOverlap></Where>";
SPListItemCollection myItems = myList.GetItems(query);

My past events are not there.

I have mentioned the start date as below:

CalDate = new DateTime(2009,2,1)

But didnt worked out.. My calendar starts from today's date.

1 Answer 1

          <FieldRef Name='EventDate' />
          <FieldRef Name='EndDate' />
          <FieldRef Name='RecurrenceID' />
          <Value Type='DateTime'>

Instead of <Now /> use <Today/>

Ref : CAML Queries, DateRangesOverlap, and Today, oh my!, see the comment on blog too!

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.