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 / Need help to calculate...
Power Automate
Unanswered

Need help to calculate time between 2 dates, excluding non-business hours

(0) ShareShare
ReportReport
Posted on by 6

Hi everyone,

 

I am building a flow that post automated messages everytime a new email arrives.

Every new email is a new job and has a deadline: it is always current time + 5 business hours.

 

So I used the addHours function, and it works as expected:

addHours(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 5, 'dddd dd MMM yyyy HH:mm')

 

The result is something like this: Monday 29 May 2023 23:58

 

But I have 2 issues:

- our business hours are 9am - 5pm, the addHours function simply adds +5 hours, how can I tell the system to exclude any hour between 5pm and 9am?

- how do I exclude Saturdays and Sundays?

 

Thank you in advance for any piece of information! 😀

Categories:
I have the same question (0)
  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @BlindBot 

     

    Different ways you could do this. Try this.

     

    image.png

     

    Expressions I used above are:

     

    addHours(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 5, 'HH')
     
    addHours(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 5, 'dddd')
     
    image.png
     
    Above expression is as follows:
    addHours(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 5, 'dddd dd MMM yyyy HH:mm')
     
  • BlindBot Profile Picture
    6 on at

    Thank you for your help!

     

    The condition function is not ideal, as it's bypassing requests that come late. 

     

    Some requests might come on a Sunday, or during the week at midnight.

    if so, the deadline should be:

    - next business day

    - 9am + 5H

     

    I think I need a formula...

  • abm abm Profile Picture
    32,865 Most Valuable Professional on at

    Hi @BlindBot 

     

    You could split the condition to check If its Saturday then

     

    addDays(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 2, 'dddd dd MMM yyyy 09:00')

     

    For Sunday

     

    addDays(convertTimeZone(utcNow(),'UTC','Romance Standard Time'), 1, 'dddd dd MMM yyyy 09:00')

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard