views:

629

answers:

2
+1  Q: 

CAML Query

I'd like to have a CAML query to get the events from a calendar list.

I want to get all the events including Today in the upcoming 30 or so days.

So far I have:

<Where>
  <DateRangesOverlap>
    <Geq>
      <FieldRef Name=\"EventDate\" />
      <Value Type=\"DateTime\">
        <Today />
      </Value>
    </Geq>
    <FieldRef Name=\"EndDate\" />
    <FieldRef Name=\"RecurrenceID\" />
    <Value Type=\"DateTime\">
      <Month />
    </Value>
  </DateRangesOverlap>
</Where>

This does not work :( Any ideas?

A: 

The recurrence does not actually add all the events into the list, but the CAML can only query from "actual" events stored in the list.

Nat
+1  A: 

As Nat has said you hint (but don't specify) that you are using recurring events in your calendar list so I am assuming that is the part that's not working?

You need to set the SPQuery.ExpandRecurrances and SPQuery.CalendarDate property prior to running the CAML query and you can only do this using the object model, not the web services or by setting an attribute in CAML.

Further - IIRC this will only expand out instances of recurring events that occur in the same calendar month as .CalendarDate so you have to run it multiple times to get a multi-month view.

This is by far the best reference covering recurring events I have found.

Welcome to the nightmare of recurring events in SharePoint!

Ryan