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

How to exclude the weekend from date range

Hi All, 

I want to exclude the weekends and calculate the remaining dates in a date range.

Currently, I m using addDays function as follows in two conditions. But this is only adding 10 days(without considering number of weekend days)  if RemainigDaysVariable > 10 days (1st condition) or calculate the remaining days if RemainigDaysVariable< 10 days (2nd condition)

in 1st condition 

addDays(utcNow(),10,'dd-MM-yyyy')

 

in 2nd condition
addDays(utcNow(),variables('RemainigDaysVariable'),'dd-MM-yyyy')

 

Following are the variables I have used on the 2nd condition

RemainigDaysVariable-> div(sub(variables('WindowEnd'),outputs('Compose2')),864000000000)

Compose2-> ticks(variables('ApprovedDateVariable'))

approverdatevariable.png

 

But now what I want to do is based on the ApprovedDateVarible I want to calculate the remaining business days and assigned that value to RemainigBusinessDaysVariable

Then If the RemainigBusinessDaysVariable> 10 business days 

then addDays(utcNow(),Add10Businessdays,'dd-MM-yyyy')<--- condition 1

else addDays(utcNow(),variables('RemainigDaysVariable'),'dd-MM-yyyy')

 

Much appreciate your help. 

Thanks.

3 REPLIES 3
Super User II
Super User II

@Vidanaw 

Hi there.  I might not be clear on the question, but since 10 business days is basically two weeks, could you not just add 14 days?

 

Keep us posted.

-Ed-

 

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Highlighted

@edgonzales 

Thanks for your reply.

 

But how can I calculate the RemainigDaysVariable-> div(sub(variables('WindowEnd'),outputs('Compose2')),864000000000) correctly excluding weekends.

for example, if I get approval today which is 15/11/2019 and the WindowEnd date is 27/11/2019, the number of RemainigDaysVariable must be 8 days(excluding weekends), but based on my above calculation the number of RemainigDaysVariable is 12 days wich is incorrect.

Can you please tell me how to correct this.

Thanks.

Highlighted
Super User II
Super User II

Hi

I've discovered the solution to this issue for another user here on the community, and I have written a blog article that explains the solution in detail. Check it out here:
https://manueltgomes.com/microsoft/flow/find-next-business-day/

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

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.

Top Solution Authors
Top Kudoed Authors
Users online (7,881)