web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Power Automate flow Ad...
Power Automate
Answered

Power Automate flow AddHours to exclude weekends.

(0) ShareShare
ReportReport
Posted on by 779

Hello everyone,

 

I want to create a flow that add 12 hours to a time that only includes Business Hours (08:00 - 17:00).

 

Example:

Monday 08:42 am add 12 hours

 

Output:

Tuesday 11:42 am

 

Example:

Friday 08:42 am add 12 hours

 

Output

Monday 11:42 am

 

Hopefully someone can help me.

Categories:
I have the same question (0)
  • abouchaalaBAIT Profile Picture
    932 Moderator on at

    Hello, 

    you can use this technique :

    If dayOfWeek(yourDate) equals 1 or 2 or 3 or 4 (Monday to Thursday) => Add 12 hours

    If dayOfWeek(yourDate) equals 5 (Friday) => Add 24 + 24 + 24 + 12 in order to skip Saturday and Sunday

    If dayOfWeek(yourDate) equals 6 (Staurday) => Add  24 + 24 + 12 in order to skip  Sunday

    etc ... 

     

    ----------------------------------------------------------
    If I have answered your question, please mark your post as Solved. 🆗✔️
    If you like my response, please give it a Thumbs Up. 👍
    You can accept more than one post as a solution.

     

    11.png

  • Caleb62881177 Profile Picture
    779 on at

    @abouchaalaBAIT I am not sure if your solution factors in not adding hours to the time when it's not in Business hours.

     

    Example:

    6pm, 7pm, 8pm etc ...

  • Caleb62881177 Profile Picture
    779 on at

    And I cannot see what you did with the 2 Composes.

  • abouchaalaBAIT Profile Picture
    932 Moderator on at

    @Caleb62881177 you can add a condition to check if yourtime is between 8AM and 5PM

    If for exemple your date = "01/01/2023 06:00 PM" you should check if your date is greater than  "01/01/2023 05:00 PM" or less than "01/01/2023 08:00 AM".

    Give it a try and let me know

  • Caleb62881177 Profile Picture
    779 on at

    In the flow I have to use addHours() expression to add the 12 hours to the time I use. I still get out of Business Hours results.

  • abouchaalaBAIT Profile Picture
    932 Moderator on at

    I better understand now. 

    what you can do is : 

    1. get the difference between yourdateTime and Today 5PM (Ex : your DateTime = 01/01/2023 12 PM) => result should be 5 
    2. get the difference between 9 hours (Business hours) and the result of previous step (Ex : 9-5 = result2 => 4)
    3. Add 4 hours to next day from 8AM 
      1. Next day should be determined depending dayOfWeek(yourDate) (Refer to my first repy and adapt..)

    Hope this will help

    ----------------------------------------------------------
    If I have answered your question, please mark your post as Solved. 🆗✔️
    If you like my response, please give it a Thumbs Up. 👍
    You can accept more than one post as a solution.

  • Caleb62881177 Profile Picture
    779 on at

    Hi @abouchaalaBAIT ,

     

    I was thinking about the calculations for the solution and I figured out that for Monday to Friday you add 16 hours to the time and from Friday to Monday you add 63 hours.

  • abouchaalaBAIT Profile Picture
    932 Moderator on at

    @Caleb62881177 I don't think so 

    Let's take your first exemple 

    Example:

    Monday 08:42 am add 12 hours should be => Tuesday 11:42 am

    By adding 16 hours the result will be monday night. 

     

  • Caleb62881177 Profile Picture
    779 on at

    @abouchaalaBAIT  I meant you first add the 12 hours to 08:42 which makes it 20:42, but if you add 15 hours to it then it becomes 11:42.

  • abouchaalaBAIT Profile Picture
    932 Moderator on at

    @Caleb62881177 but this will not work for Monday 4:55 pm results should be Wednesday if I understood correctly

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard