Free Support Forum -

Can't get GenerateOccurrences to work

I am trying to get GenerateOccurrences to work. I know that the demo will only generate recurrences for dates between 1/1/2000 and 6/30/2000. I am trying to test dates in that range. Please see example code below.

DaysOfWeek days = new DaysOfWeek();

Weekly weekly = new Aspose.Recurrence.Weekly(1,days);

DateArray WeeklyArray = new DateArray();

DateTime begin = new DateTime(2000,2,1);
DateTime end = new DateTime(2000,4,1);

When this executes, WeeklyArray has 0 dates.



Hi Toby,

Your code is correct, but you also need to set StartDate property which specifies the start date of the recurrence pattern itself. It defaults to today that’s why you don’t get any occurrences of this pattern back in 2000.

//For example
weekly.StartDate = new DateTime(2000, 2, 1);

The dates you specify in GenerateOccurrences are just search range start and end dates - they are not part of the recurrence pattern.