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.
Great I have been searching for days for this
ReplyDeleteThank you
Glad I could help. :)
ReplyDeleteGood Day I am new to sharepoint and coding how would I use this to populate a java calendar ?
ReplyDelete