cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ramonjairo31
Helper II
Helper II

Exclude weekends using addday

Hello people, 


I need some help on this point, I have a flow in which it receives a date and a day as a result show the date plus the amount of days but now I need to exclude weekends from the result

 

This is my formula that works perfectly, however, this includes weekends and I would like to take weekends out

 

 

adddays(outputs('Set_Start_Date'),add(int(items('Apply_to_each')?['Day']),int(1)))

 

8 REPLIES 8
ScottShearer
Super User III
Super User III

@Ramonjairo31 

You'll want to use the dayOfWeek() expression and apply it to the date that you have calculated.  dayOfWeek returns 0 for Sunday and 6 for Saturday.  So, you might, for example, add one more day if the result is 0 and two days if the result is 6.  

You could do all of this in a single expression, but it would be really ugly - I would divide it into two or three expressions probably inside of Compose actions.  

Let me know if you need more help.

 

 

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

Scott

@ScottShearer 

 

I'm a beginner in Power Automate, what would be the expression using IF could you please guide me on this

 

 

Thanks Mr. @ScottShearer 

Hi @Ramonjairo31 ,

 

Capture.JPG

 

To use Day of week : 

dayOfWeek(variables('Date')) : Replace variables('Date') with your variable

 

Thanks 

@Ramonjairo31 

Please see my screen shot below.  A Switch action is appropriate here.image.png

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

Scott

Im trying to emulate your flow but is showing a error

image.png

Ramonjairo31
Helper II
Helper II

This is my currently flow

 

image.png

 
 

 

image.png

@Ramonjairo31 ,

 

Where are you using the Dayofweek functionality in the screenshots you mentioned. Also where you are getting the error what variable are you using to get the output in switch. 

 

Thanks

@ManishJain 

My suggestion is as follows

  1. Create a string variable near the top of your Flow
  2. In the Switch statement/action, use your current expression inside of a dayOfWeek() expression
  3. The cases should be 1, 6 and the default case.  The numbers 1 and 6 represent Saturday and Sunday.
  4. In the case section of the Switch action, add 0, 1 or 2 days to the output of your expression as appropriate and store the result in the variable that you initialized.
  5. When updating the SharePoint item, set the Actual end date column equal to the variable

 

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

Scott

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (49,147)