title: CAML query to get SharePoint calendar events
body: <p>I'm trying to get all the calendar events for a specific view for the next 12 months using a CAML query. I'm using the PHP SoapClient to do this. Here is my code;</p>
  
  <pre><code>$query = "&lt;Query&gt;
      &lt;Where&gt;
          &lt;DateRangesOverlap&gt;
              &lt;FieldRef Name='EventDate' /&gt;
              &lt;FieldRef Name='EndDate' /&gt;&lt;FieldRef Name='RecurrenceID' /&gt;
              &lt;Value Type='DateTime'&gt;&lt;Year /&gt;&lt;/Value&gt;
          &lt;/DateRangesOverlap&gt;
      &lt;/Where&gt;
      &lt;OrderBy&gt;&lt;FieldRef Name='EventDate' /&gt;&lt;/OrderBy&gt;
  &lt;/Query&gt;";
  
  $query_options = "&lt;QueryOptions&gt;
      &lt;RecurrencePatternXMLVersion&gt;v3&lt;/RecurrencePatternXMLVersion&gt;
      &lt;ExpandRecurrence&gt;TRUE&lt;/ExpandRecurrence&gt;
      &lt;CalendarDate&gt;2013-01-01T12:00:00Z&lt;/CalendarDate&gt;
  &lt;/QueryOptions&gt;";
  
  $soapClient = new SoapClient($wsdl, $authParams);
  $params = array('listName' =&gt; $list_name, 'viewName' =&gt; $view_name, 'rowLimit' =&gt; $row_limit, "query" =&gt; $query, "query_options" =&gt; $query_options);
  
  $rawXMLresponse = $soapClient-&gt;GetListItems($params)-&gt;GetListItemsResult-&gt;any;
  </code></pre>
  
  <p>The results are being pulled from the correct view but it's returning all events from the start of the list (September 2012) until the last event (July 2013). No matter whether I change the 'CalendarDate' or change the DateTime value to 'Month' it still gives me the same result. Surely this query should be fetching only the events for the DateTime period?</p>
  
  <p>Any help would be much appreciated!</p>