Is there any way to avoid counting certain days of the week?

Currently, we need to create a specification that counts only three days of the week: Monday, Wednesday, and Friday.

Example.
For example, if 2021/11/18 is a Thursday, three business days later, the day will be
1、2021/11/19 Friday
2,2021/11/22 Monday
3,2021/11/24 Wednesday

We would like to make it so that if you enter November 18, the date will be converted to November 24.
So, is there any way to count only certain days of the week, or not count certain days of the week?

Hi,

How about the following?

workingDay={DayOfWeek.Monday,DayOfWeek.Wednesday,DayOfWeek.Friday}
targetDate = New Date(2021,11,18)

then

targetDate.AddDays(Enumerable.Range(1,7).Where(Function(i) workingDay.Contains(targetDate.AddDays(i).DayOfWeek)).Skip(2).Take(1).First)

Sequence1.xaml (5.6 KB)

Regards,

1 Like

I have never seen such a useful way of writing before.
Thank you very much for introducing it.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.