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 / Calculation Time Durat...
Power Automate
Answered

Calculation Time Duration Within Specific Time Period

(0) ShareShare
ReportReport
Posted on by 16

Hi Power Automate Community,

 

I need help to build a flow that will determine each sharepoint item time duration,
Given the start timing is the sharepoint item creation date and end timing is current time.
However, the Time Duration calculation must within specific time period as below:

DayTime Period StartTime Period End
Monday8:00 AM9:00 PM
Tuesday11:00 AM9:00 PM
Wednesday3:00 PM9:00 PM
Thursday10:00 AM9:00 PM
Friday8:00 AM9:00 PM
SaturdayN/AN/A
SundayN/AN/A

 

For Example, if the sharepoint item creation date is dated Tuesday (30 May 2023) at 9 AM and current time is Friday (2 June 2023) at 11 AM.


The Time Duration calculation should be like below:

Tue Duration = 9.00 PM - 11.00 AM
Wed Duration = 9.00 PM - 3.00 PM
Thu Duration = 9.00 PM - 10.00 AM
Fri Duration = 11 AM - 8.00 AM

Total Duration = Tue Duration + Wed Duration + Thu Duration + Fri Duration

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at

    Hi @nazmisyaz1 

     

    Duration needs to be calculated in hours or days ?

     

    Also does date is not considered while calculating duration ?

     

     

  • nazmisyaz1 Profile Picture
    16 on at

    Hi @Nived_Nambiar ,

    The Duration will be in hours, and date is not considered actually, just the day as need to check the exact time period for different days

  • Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at

    Hi @nazmisyaz1 

     

     

    Give a try with this expression to compute duration (in hours)

     

    div(mul(sub(ticks(utcnow()),ticks(
    items('Apply_to_each')?['Created']
    )),100),3600000000000)
     
     
    Hope this helps !
     
     
  • nazmisyaz1 Profile Picture
    16 on at

    Hi @Nived_Nambiar ,

     

    The expression given can calculate the duration between current time and start time only, 

    but I need the duration to comply below table time period.
    For the timing outside of this table, will not calculated in the duration

    DayTime Period StartTime Period End
    Monday8:00 AM9:00 PM
    Tuesday11:00 AM9:00 PM
    Wednesday3:00 PM9:00 PM
    Thursday10:00 AM9:00 PM
    Friday8:00 AM9:00 PM
    SaturdayN/AN/A
    SundayN/AN/A
  • Nived_Nambiar Profile Picture
    18,136 Super User 2026 Season 1 on at

    Hi @nazmisyaz1 

     

    One question may be i am confused

     

    does the above table you have shared is list in sharepoint ?

     

     

  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @nazmisyaz1 ,

     

    Please try:

    vbofengmsft_0-1685694384962.png

    vbofengmsft_1-1685694423954.png

    1\

    if(
     equals(dayOfWeek(variables('DateTamp')),1),
     div(sub( max(ticks(variables('DateTamp')),ticks(addHours(startOfDay(variables('DateTamp')),8))),min(ticks(utcNow()),ticks(addHours(startOfDay(variables('DateTamp')),21)))),36000000000),
     if(
    	 equals(dayOfWeek(variables('DateTamp')),2),
     div(sub( max(ticks(variables('DateTamp')),ticks(addHours(startOfDay(variables('DateTamp')),11))),min(ticks(utcNow()),ticks(addHours(startOfDay(variables('DateTamp')),21)))),36000000000),
    	 if(
    	 equals(dayOfWeek(variables('DateTamp')),3),
     div(sub( max(ticks(variables('DateTamp')),ticks(addHours(startOfDay(variables('DateTamp')),15))),min(ticks(utcNow()),ticks(addHours(startOfDay(variables('DateTamp')),21)))),36000000000),
    	 	 if(
    	 equals(dayOfWeek(variables('DateTamp')),4),
     div(sub( max(ticks(variables('DateTamp')),ticks(addHours(startOfDay(variables('DateTamp')),10))),min(ticks(utcNow()),ticks(addHours(startOfDay(variables('DateTamp')),21)))),36000000000),
    	 	 if(
    	 equals(dayOfWeek(variables('DateTamp')),5),
     div(sub( max(ticks(variables('DateTamp')),ticks(addHours(startOfDay(variables('DateTamp')),8))),min(ticks(utcNow()),ticks(addHours(startOfDay(variables('DateTamp')),21)))),36000000000),
    	 0
    	 )
    	 )
    	 )
     )
    )

    2\

    startOfDay(addDays(outputs('Compose'),1))

    Result

    vbofengmsft_2-1685694491832.png

     

     

    Best Regards,

    Bof

     

  • nazmisyaz1 Profile Picture
    16 on at

    Hi @v-bofeng-msft ,

     

    Thank you for your support, let me try your flow first.

  • nazmisyaz1 Profile Picture
    16 on at

    Hi @Nived_Nambiar ,

     

    No its not in the sharepoint, its a time period condition

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 304

#2
David_MA Profile Picture

David_MA 245 Super User 2026 Season 1

#3
Expiscornovus Profile Picture

Expiscornovus 243 Most Valuable Professional

Last 30 days Overall leaderboard