Calculate Time Span in Power Automate

Hysore, Ken 1 Reputation point
2021-06-21T13:57:26.47+00:00

I have a SharePoint calendar where I'm entering events with a Start Date and Time and an End Date and Time. I want to take the Start and End and determine the number of hours between the two. I will then enter the number of hours into the event.

I know I need to work with the timespan and most likely get ticks in the formula, but struggling a bit with this one.

Any help would be appreciated.

The info is all being pulled from and entered into a SharePoint calendar and im doing the automation and formulas using power automate

thanks,

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,966 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Leon Laude 85,841 Reputation points
    2021-06-21T14:01:44.903+00:00

    Hi @Hysore, Ken ,

    Please note that Power Automate is currently not supported in the Q&A forums, the supported products are listed over here https://learn.microsoft.com/en-us/answers/products.

    You may ask the experts in the dedicated Power Automate forum over here:
    https://powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity

    ----------

    If the reply was helpful please don't forget to upvote and/or accept as answer, thank you!

    Best regards,
    Leon

    0 comments No comments

  2. JoyZ 18,076 Reputation points
    2021-06-22T07:43:10.643+00:00

    @Hysore, Ken ,

    Please refer to following steps in Power Automate to calculate hours between Start Time and End Time:

    107969-image.png

    Start Compose:

    ticks(triggerBody()?['EventDate'])  
    

    End Compose:

    ticks(triggerBody()?['EndDate'])  
    

    DifferenceAshours Compose:

    div(div(mul(sub(outputs('End'),outputs('Start')),100),1000000000),3600)  
    

    Result:

    108081-image.png

    Then you could use DifferenceAshours Compose to update columns in calendar list.

    More information:

    https://powerusers.microsoft.com/t5/Building-Power-Apps/how-to-get-difference-between-two-dates-in-flow/td-p/283186


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.