Hi everyone,
I'm working on an app to help with scheduling. Basically the goal is, knowing the desired end date of a project and a few variables, I want to be able to work back and calculate when certain steps should be met. Basically, I need to subtract business days from a value.
I made a quick test app. Basically it has a text input with a number, and a date picker, and a text field with the following code, based off of this blog post.
With(
{
varStartDate: DatePicker1.SelectedDate,
varAddWeekdays: Value(TextInput1.Text)
},
DateAdd(
varStartDate,
Value(varAddWeekdays) + RoundDown(
(Weekday(
varStartDate,
Monday
) + Value(varAddWeekdays) - 1) / 5,
0
) * 2,
Days
)
)
My issue is that it works fine when I add days, but it doesn't when I need to subtract days. I've fiddled around with it but I can't quite figure it out. For example, if I have the date set to Monday, July 11th and I want to subtract 1 business day, I expect the result to be Friday July 8th, but the app returns the Sunday the 10th.
The only solution I can think of is to make a collection of all the dates backwards from the end date, and then use that to calculate everything but there has to be an easier way, right?