cancel
Showing results for
Did you mean:
Helper III

## Calculating dates, skipping weekends

Hello,
I'm looking for help regarding calculating dates and skipping weekends from the result.

The Scenario is the following:

Calendar for the start date, a numeric input for the days to add to the selected date in the start calendar and then the result to be shown in another calendar.

Thank you

2 REPLIES 2
Solution Sage

Nice Challenge! To create a little mockup for your App, I created an App with two date-pickers and a slider to choose the number of workdays to advance.

In the OnChange of the slider I added this calculation for translating workdays to full week calculations:

`With({_WeekDayStart:Weekday(DatePicker1.SelectedDate),    _AddWeekDays:Slider1.Value},    Set(varAddDays,_AddWeekDays+2*RoundDown((_AddWeekDays+_WeekDayStart-2)/5,0)))`

So what this does is that every saturday it adds 2 days to get to the next workday. The tricky thing is that you have to calculate when Saturday occurs, depending on the weekday of your start day. As Monday counts as Weekday 2, adding _WeekdDayStart-2 will move the moment you add 2 days dependent on your start day.
Now varAddDays can be used to calculate the defaultselecteddate of the second Date Picker:

`DateAdd(DatePicker1.SelectedDate,Value(varAddDays),TimeUnit.Days)`

Please like the reply and/or accept it as the solution if the answer is what you were looking for.
Helper III

Thank you @RogierE  for your help, I appreciate it.

I will try this solution and let you now, I tried many other ways, seems working but sometime the results are not accurate. So I need to keep searching for alternative solutions.

Thanks

Announcements