SharePoint: CAML for all future calendar items including recurring

Posted: 11th June 2013 in SharePoint
Tags: ,

After spending a bit of time trying to figure out the correct CAML to show all future items with the inclusion of recurring items. I thought I’d just blog it to save me the hassle if I need to use it again 

All Calendar Items CAML
  1.  
  2. var query = new SPQuery {
  3.     Query = @"<Where>
  4.                  <DateRangesOverlap>
  5.                     <FieldRef Name='EventDate'/>
  6.                     <FieldRef Name='EndDate'/>
  7.                     <FieldRef Name='RecurrenceID'/>
  8.                     <Value IncludeTimeValue='TRUE' Type='DateTime'>
  9.                         <Now/>
  10.                     </Value>
  11.                  </DateRangesOverlap>
  12.               </Where>
  13.               <OrderBy>          
  14.                 <FieldRef Name='EventDate' Ascending='TRUE'/>      
  15.               </OrderBy>",
  16.     ExpandRecurrence = true,
  17.     RowLimit = Convert.ToUInt32(this.ItemsToDisplay)
  18. };

Advertisements
Comments
  1. Joseph A says:

    Thnakyou saved alot of my time

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s