cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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.

2 REPLIES 2
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.

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.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Kudoed Authors (Last 30 Days)
Users online (5,337)