Skip to main content
replaced http://sharepoint.stackexchange.com/ with https://sharepoint.stackexchange.com/
Source Link

Setting query.ExpandRecurrence = true didn't help. I also tried the solution suggested herehere. Somehow I can't get it working with recurring events. For the following example I'd like to get the 2nd and 3rd "OK Repeating Event" and the "OK1" event since it starts earlier than "OK2" CalendarImage

Setting query.ExpandRecurrence = true didn't help. I also tried the solution suggested here. Somehow I can't get it working with recurring events. For the following example I'd like to get the 2nd and 3rd "OK Repeating Event" and the "OK1" event since it starts earlier than "OK2" CalendarImage

Setting query.ExpandRecurrence = true didn't help. I also tried the solution suggested here. Somehow I can't get it working with recurring events. For the following example I'd like to get the 2nd and 3rd "OK Repeating Event" and the "OK1" event since it starts earlier than "OK2" CalendarImage

Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
Razze
  • 367
  • 3
  • 16

Caml Query on calendar to get the next x events (including recurring)

So far I'm able to get the next x events (without recurring events). Code:

    private SPListItemCollection GetNextEvents(SPList eventCalendar)
    {
        DateTime currentDateTime = DateTime.Now;
        string currentDateTimeString = SPUtility.CreateISO8601DateTimeFromSystemDateTime(currentDateTime);
        SPQuery query = new SPQuery();
        query.RowLimit = 3;
        query.ExpandRecurrence = true;            
        query.Query = "<Where>" +                    
                          "<And>" +
                            "<Geq>" +
                                "<FieldRef Name='EndDate' />" +
                                "<Value Type='DateTime' IncludeTimeValue='True'>" +
                                    currentDateTimeString +
                                "</Value>" +
                            "</Geq>" +
                            "<Geq>" +
                                "<FieldRef Name='EventDate' />" +
                                "<Value Type='DateTime' IncludeTimeValue='True'>" +
                                    currentDateTimeString +
                                "</Value>" +
                            "</Geq>" +
                          "</And>" +
                        "</Where>" +
                        "<OrderBy>" +
                            "<FieldRef Name='EventDate' />" +
                        "</OrderBy>";            

        SPListItemCollection itemColl = eventCalendar.GetItems(query);

        return itemColl;
    }

Setting query.ExpandRecurrence = true didn't help. I also tried the solution suggested here. Somehow I can't get it working with recurring events. For the following example I'd like to get the 2nd and 3rd "OK Repeating Event" and the "OK1" event since it starts earlier than "OK2" CalendarImage