cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Vidanaw
Level: Powered On

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
Super User

Re: How to exclude the weekend from date range

@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
Vidanaw
Level: Powered On

Re: How to exclude the weekend from date range

@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.

Super User
Super User

Re: How to exclude the weekend from date range

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
firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (4,274)