cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Add on working days to Today()

I am trying to, on the push of a button, set a date which is Today() + X number of working days. I cannot figure out how to get this working to account for every eventuality. I am going to be creating a number of tasks (list items) at one time using Patch and all of them will have a different Due Date (Today() + X days).

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Add on working days to Today()

Hi @sammybridge 

In the OnSelect property your button, you can add the following code:

Set(varDaysToAdd,3);
Set(varResult, DateAdd(Today(),
Value(varDaysToAdd) + 
RoundDown(Value(varDaysToAdd) / 5, 0)*2+
Switch(Weekday(Today()),5,If(Mod( Value(varDaysToAdd) , 5)>0,2,0),
                                         4,If(Mod( Value(varDaysToAdd) , 5)>1,2,0),
                                         3,If(Mod( Value(varDaysToAdd) , 5)>2,2,0),
                                         2,If(Mod( Value(varDaysToAdd) , 5)>3,2,0),
                                         1,If(Mod( Value(varDaysToAdd) , 5)>4,2,0))
)
)

The variable varDays defines the number of days to add (3 in this example).
The set statement stores the result of the calculation in the variable varResult.

This formula is based on @Siennas logic to exclude to exclude Saturdays & Sundays, so the credit goes to him. 

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Adding-working-days-and-hours-to-a-... 

 

View solution in original post

2 REPLIES 2
Highlighted
Responsive Resident
Responsive Resident

Re: Add on working days to Today()

Hi @sammybridge,

 

It may be that the DateAdd() function could work for you. The syntax is DateAdd(date, number_of_units, unit)

 

So in your instance, if you can pre-determine somewhere in your app for the amount of days to add for each list item, you can simply use DateAdd(Today(), number_of_days, Days), where number_of_days refers to the value assigned to this list item.

Highlighted
Super User III
Super User III

Re: Add on working days to Today()

Hi @sammybridge 

In the OnSelect property your button, you can add the following code:

Set(varDaysToAdd,3);
Set(varResult, DateAdd(Today(),
Value(varDaysToAdd) + 
RoundDown(Value(varDaysToAdd) / 5, 0)*2+
Switch(Weekday(Today()),5,If(Mod( Value(varDaysToAdd) , 5)>0,2,0),
                                         4,If(Mod( Value(varDaysToAdd) , 5)>1,2,0),
                                         3,If(Mod( Value(varDaysToAdd) , 5)>2,2,0),
                                         2,If(Mod( Value(varDaysToAdd) , 5)>3,2,0),
                                         1,If(Mod( Value(varDaysToAdd) , 5)>4,2,0))
)
)

The variable varDays defines the number of days to add (3 in this example).
The set statement stores the result of the calculation in the variable varResult.

This formula is based on @Siennas logic to exclude to exclude Saturdays & Sundays, so the credit goes to him. 

https://powerusers.microsoft.com/t5/Building-Power-Apps-Formerly/Adding-working-days-and-hours-to-a-... 

 

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,862)