I want to get all calendar items from today onwards including any recurring event items.
Problem:
CAML and SharePoint can be a pain.
Solution:
SPQuery query = new SPQuery(); string queryString = @" <Where> <DateRangesOverlap> <FieldRef Name=""EventDate""/> <FieldRef Name=""EndDate""/> <FieldRef Name=""RecurrenceID""/> <Value IncludeTimeValue=""TRUE"" Type=""DateTime""> <Now/> </Value> </DateRangesOverlap> </Where> <OrderBy> <FieldRef Name=""EventDate"" Ascending=""TRUE""/> </OrderBy> "; query.Query = queryString; query.ExpandRecurrence = true;
Note:
You should add a query.RowLimit so you don't get too many items back. But that's up to you.