Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

Instead of <Now /> use <Today/>

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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