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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Recurrence - Running a...
Power Automate
Unanswered

Recurrence - Running a flow during business hours on business days

(2) ShareShare
ReportReport
Posted on by 16

Hi all, i figured i would share this with the community in case it would help out someone as other posts here helped me figure out some stuff for my first production flow successfully running.

 

It's super simple but a bit crude (you have to either readjust to daylights savings time or widen the range) and doesn't use any calendars from your company at least as written.  Follow these simple steps but please read the full post as there is a drawback with using this approach.

 

1. Create a condition step.

2. On the "no" branch, add the action "Terminate" (which should be easier to search for).

3. Leave the "yes" branch blank and put any actions after it.

4. In the condition step, click on "edit in advanced mode" and enter the following:

 

@and(
 or(equals(dayofweek(addhours(utcnow(), -6)), 1),
 or(equals(dayofweek(addhours(utcnow(), -6)), 2),
 or(equals(dayofweek(addhours(utcnow(), -6)), 3),
 or(equals(dayofweek(addhours(utcnow(), -6)), 4),
 equals(dayofweek(addhours(utcnow(), -6)), 5))
 )
 )
 ),
 and(greaterOrEquals(int(formatDateTime(addhours(utcnow(), -6),'%H')),8),
 lessOrEquals(int(formatDateTime(addhours(utcnow(), -6),'%H')),19))
)

5.  Adjust the above -6 (which is currently central time), and the hours [the 8 and 19 at the bottom expression].  The times are in 24 hour notation.

 

6.  Add another "or" clause in the dayofweek area if you need to add Saturday.  The 1-5 is M-F.  Sunday is 0 and Saturday is 6.

 

Now to the two critical details.  With the workflow written like this, you will want to kick it off as a recurrence.  You can set it to run just daily (day for unit and 1 for each day) but this is really written as is for hour increments.  I myself set it to every 2 hours.  The problem with having it run every hour or even two, it does start to eat at your free flow quota pretty quickly.  Here is the approximate number of flows from your quota per month if you need to decide how important it is.

 

Every hour: 720

Every two hours: 360

Every three hours: 240

Every four hours: 180

Every eight hours: 90

 

Keep in mind as you go to more time between, depending on what you have your start time set to, you can actually start missing frequency pretty badly.  Also, I highly recommend for most people, set a start time in the advanced recurrence to start at an off hour.  So start it at 2017-05-05T20:10:00Z instead of 2017-05-05T20:00:00Z for instance.

 

I hope this helps someone, good luck on your flow adventures.

 

 

 

 

 

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @gosubtle,

     

    Thanks for sharing!

    I wrote a similar condition to check the working hours, see:

    How to tell if the current time is within the Business hours

    And some notes for using it.

    Regards,

    Michael

  • timr Profile Picture
    12 on at

    Hi @v-micsh-msft,

     

    I'm unable to access your link on telling if it is business hours. Can you assist as this would be very helpful?

     

    Thanks!

    Tim

  • v-micsh-msft Profile Picture
    Microsoft Employee on at
    How to tell if the current time is within business hours

    Question

    Can you write a condition to check whether current time is within business hours?

    Answer

    Currently there is no action or feature available to allow you check whether the current time is within business hours.

     

    The following steps outline a way to check the hour field against a given time. This makes use of UtcNow() function as the available input value.

     

    Steps:

    1. Add a condition, click Advanced options

    2. Copy and paste the following formula:

       @and

            GreaterOrequals(

                       formatdatetime(utcnow(),'HH:ss'),

                       formatdatetime('8:00','HH:ss')

              ),

             lessOrEquals(

                       formatdatetime(utcnow(),'HH:ss'),

                       formatdatetime('18:00','HH:ss')

               )

          )

    In the condition above, we define the working hour as 8:00 to 18:00 in UTC time zone.

     

    The condition would check whether the given time is within the hour range. If it is, it triggers the wanted actions.

     

    As the date/time format by default contains the year, month, and day, we need to use the formatdatetime function to isolate the time information.

     

    You may also use dayofweek with the And function to disregard Saturday and Sunday:

     

    @and(

          not(equals(dayofweek(UtcNow()),0)),

          and(

               not(equals(dayofweek(UtcNow()),6)),

               and(

                GreaterOrequals(

                       formatdatetime(utcnow(),'HH:ss'),

                       formatdatetime('8:00','HH:ss')

                                         ),

                 lessOrEquals(

                       formatdatetime(utcnow(),'HH:ss'),

                       formatdatetime('18:00','HH:ss')

                                     )

                       )

                 )

    )

     

     

    Please note that the time settings in Microsoft Flow use UTC. You may need to convert the range for your local time zones to work.

     

    If you have any further questions, or you need any further assistance to customize this flow, please feel free to post in the Microsoft Flow forum.

     

    Regards,

    Michael Shao

  • AlanPs1 Profile Picture
    2,471 on at

    Hi, Thanks for sharing.

     

    I took a slightly diferent approach so thought i'd link it here to see what others thought.

     

  • timr Profile Picture
    12 on at

    Thank you for the assistance. Since I need the flow to run 7 days a week I didn't use the day of week function, but I did make some modifications and ended up with the following:

     

    @and(

       GreaterOrequals(

         convertTimeZone(utcnow(), 'UTC', 'Central Standard Time', 'HH:mm'),

         formatdatetime('6:00','HH:mm')

       ),

       lessOrEquals(

         convertTimeZone(utcnow(), 'UTC', 'Central Standard Time', 'HH:mm'),

         formatdatetime('22:00','HH:mm')

       )

    )

  • AlanPs1 Profile Picture
    2,471 on at

    Nice work timr.

    Great to see more tailored usage of date & time to suit.

     

    *Thumbs up*

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @v-micsh-msft!

     

    If I need to calculate a 'Due Date' that is 30 BUSINESS DAYS from today, could I utilize any of this logic (I think I could utilize the parts you mentioned about excluding weekend days, but am not sure exactly how 😀)?

     

    So far, I know that this formula gives me 30 days from today, but that includes weekends: 

    formatDateTime(addDays(utcNow(), 15), 'yyyy-MM-dd')

     

    Any ideas on how to calculate 30 business days from today would be greatly appreciated!!!

  • Samir2 Profile Picture
    6 on at

    Very useful, many many thanks

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
11manish Profile Picture

11manish 321 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 244

#3
Henil Profile Picture

Henil 102

Last 30 days Overall leaderboard