I'm facing a problem building a caml query for the calendar list. Here is my caml query
SPQuery query = new SPQuery();
StringBuilder sb = new StringBuilder();
sb.Append("<Where>");
sb.Append("<And>");
sb.Append("<DateRangesOverlap>");
sb.Append("<FieldRef Name='EventDate' /><FieldRef Name='EndDate' /><FieldRef Name='RecurrenceID' />");
sb.Append("<Value Type='DateTime'><Month /></Value>");
sb.Append("</DateRangesOverlap>");
sb.Append("<Geq><FieldRef Name='EventDate'/><Value Type='DateTime'><Today Offset='-1'/></Value></Geq>");
sb.Append("</And>");
sb.Append("</Where>");
sb.Append("<OrderBy><FieldRef Name='EventDate' /></OrderBy>");
query.RowLimit = numberOfUpcomingEvents;
query.Query = sb.ToString();
query.ExpandRecurrence = true;
query.CalendarDate = DateTime.Now;
The problem is that it won't work properly if there is an recurring event that starts before current date but the next recurrence is on current date after. How to retrieve recurrence events as single events?
Anyone has suggestions?