Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Solution
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

How to calculate difference between two times in Power Automate

Posted on February 6, 2022April 6, 2022 by Tom

“I’ve got two times, the task start time and end time, how do I calculate a difference in minutes or hours with Power Automate?”


One of the features missing in Power Automate is a calculation of a difference between two dates / times. There’re many operations with date, you can calculate a date, you can format a date, but you can’t easily calculate a difference. To do that you’ll need a combination of expressions, and that’s what this post is about.

Calculate the number of ticks

As already explained in the post on Excel based reminders, Power Automate has an expression called ticks(…). This expression will take a date and calculate a number of ticks for that date. One tick is 100 nanoseconds, starting with 1st of January 0001 00:00:00. For example, 6th of February 2020 at 19:28 will return 637797689122217300 ticks.

When you calculate a difference between two dates / times, you must get ticks for both of the dates, e.g.

today - yesterday
ticks(today) - ticks(yesterday)
ticks(utcNow()) - ticks(addDays(utcNow(),-1))

Once you have the two numbers of ticks, you can subtract one from the other with the sub(…) expression.

sub(ticks(utcNow()),ticks(addDays(utcNow(),-1)))

= 864000000000

Note: if you end up with a negative number, you should switch the two dates in the expression.

Convert ticks into more readable unit

The result of the subtraction should be then converted into a more understandable number. You don’t want to show users the difference in billions. Use the div(…) expression to divide the number by a number representing the desired unit.

Divide byTo get
864000000000days
36000000000hours
600000000minutes
10000000seconds

For example, to get the number of minutes between yesterday and today:

div(sub(ticks(utcNow()),ticks(addDays(utcNow(),-1))),600000000)
Power Automate calculate difference times

Summary

To calculate a difference between two dates / times in Power Automate, you must combine multiple expressions. Calculate the number of ticks for each date, and then divide it by a number to get the desired unit. Start from 100 nanoseconds (1 tick) and divide it by a number big enough to get the days/hours/minutes.

And if you’d like to get the result as a decimal number, apply float(…) on one of the numbers.


🚀 Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

11 thoughts on “How to calculate difference between two times in Power Automate”

  1. Steve Myles says:
    April 27, 2022 at 8:13 am

    Tom,
    on a similar topic I am trying to covert an Excel Time only column to Sharepoint time only column with power automate.
    I can do this for a date only using technique described here

    https://normyoung.ca/2020/07/20/import-excel-data-into-an-existing-sharepoint-list-using-power-automate/

    Can you suggest how to modify this for a time only column

    Thanks
    Steve

    Reply
  2. Steve Myles says:
    April 28, 2022 at 11:55 am

    Figured it out

    formatDateTime(variables(‘varStartTime’),’HH:mm tt’)

    Reply
    1. Tom says:
      May 3, 2022 at 7:47 pm

      Hello Steve,
      I’m glad that you solved it, thank you for sharing the solution.

      Reply
  3. Paul says:
    September 8, 2022 at 10:06 pm

    Nice write up Tom, solved my problem right away.

    Reply
  4. Pingback: Chris Webb's BI Blog: Calling The Power BI Enhanced Refresh API From Power Automate, Part 6: Cancelling Dataset Refreshes Chris Webb's BI Blog
  5. Iron Arm says:
    October 6, 2022 at 8:48 pm

    Power Automate actually does have a “dateDifference” function under expressions. But it returns it in time format. Ex: 00:01:57.8418729

    Reply
    1. Tom says:
      October 14, 2022 at 10:28 am

      Hello Iron,
      I noticed that there’s this new expressions, but I don’t like the result format. I’d much prefer if they allowed you to enter a 3rd parameter with a unit, e.g. dateDifferece(…,…, ‘seconds’)

      Reply
  6. Pingback: Playing with Power Automate and Calendar events – rakhesh.com
  7. Rachayeeta Mallik says:
    November 29, 2022 at 3:26 pm

    How to calculate the difference between two dates excluding the weekend

    Reply
    1. Tom says:
      December 5, 2022 at 8:13 pm

      Hello Rachayeeta,
      I don’t know, I never needed that.

      Reply
  8. Manoela Giovanna Ramos de Mendonça says:
    April 12, 2023 at 1:05 pm

    Gostaria de criar um alerta no planner atraves da automatização do power automate, porém tenho a data oficial que é a entrega da tarefa, mas queria que criasse um alerta que antecede 3 dias a data oficial, teria como?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

🚀 Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Get the Approval Process solution to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Are your approvals stuck due to unavailable approvers?

Keep your approvals running with the Approval task delegation app! Reassign any existing approval task to another user with a single click - no more waiting for absent approvers!

Power Automate approval task delegation ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundle—everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes