I have an app that uses date pickers. There are actually 11 date pickers that require different dates. My primary date picker DataCardValue8 is the basis for the calculations for all the other date pickers. Some date pickers will add 1 day, others 5 days, while still others 10 days. I'll have to duplicate the formula on each individual date picker. What I want is to exclude weekends so I always end up with a business day in the date picker.
I came across a solution that looks plausible, but when applying it in my PowerApps, I get an error. The error states that the function DateAdd has some invalid arguments... Can someone help me get this working or suggest a different way to solve my problem?
Here is the code that I am using in my DefaultDate for one of the subsequent date pickers (in this example I am adding 5 days). I found the code at the following link: https://www.matthewdevaney.com/how-to-add-business-days-to-a-date-in-power-apps-excludes-weekends/
With(
{
varStartDate: DataCardValue8.SelectedDate,
varAddWeekdays: 5
},
DateAdd(
varStartDate,
Value(varAddWeekdays) + RoundDown(
(Weekday(
varStartDate,
Monday
) + Value(varAddWeekdays) - 1) / 5,
0
) * 2,
Days
)
)