Is there a way of excluding specific days of the week (Sat/Sun) or of excluding specific days with RecurrenceExpand.Expand

Asked by mrplatypus (aka Dave)
9 years ago.

Dear Support Team,

The application I'm currently working with typically works Monday through Friday.

I am using the RecurrenceExpander.Expand method to generate a table of planned future dates for a recurring event.

Is there a way of excluding specific days of the week (Saturdays, Sundays) or of excluding specific days (25th December, 1st January) from the year?

Please help.

Thanks & Regards

mrplatypus, aka Dave.

Answer posted by Dan Letecky [DayPilot]
9 years ago.

Yes, for skipping the weekend the rule would by "weekly" and the list of days would include Monday...Friday:

RecurrenceRule rule =
    RecurrenceRule.FromDateTime("1", DateTime.Today)
        .Weekly(new DayOfWeek[]
            {DayOfWeek.Monday, DayOfWeek.Tuesday, DayOfWeek.Wednesday, DayOfWeek.Thursday, DayOfWeek.Friday,});

For excluding exact days of year it will be necessary to post-process the result set manually and remove the occurrences. Just note that if the rule specifies a fixed number of occurrences this may produce undesired result (too few occurrences).

Comment posted by mrplatypus (aka Dave)
9 years ago.

Dan,

Thanks for the information - I asked specifically about specific days, to take into consideration Bank Holidays, Christmas Day, New Years Day etc..
I was hoping not to have to iterate through the resultset of all days etc but if that is the only way then that will have to do.

Thanks again.

mrplatypus (aka Dave)

This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.