One question that is frequently asked on the Power Automate discussion boards is how to find the difference between two dates. There is not currently a built-in Power Automate expression that will get the job done. To find out ho to accomplish this requirement, read on...
In my scenario, I will want to find the difference in days between a date stored in a SharePoint list and the current date.
Here's what we are going to do:
- Convert the two dates to ticks
- A tick is a small faction on a second
- Subtract one date from the other
- The result will be the difference in ticks
- Convert the ticks to days
- You're done!
Step 1 - Convert to ticks
Use the ticks() expression to convert both dates to ticks
Step 2 - Get the difference in ticks
Use the sub() expression to find the difference between the two dates in ticks
Step 3 - Convert the difference in ticks to days
There are 864000000000 ticks in a day. Divide the difference in ticks by 864000000000 to find the difference in days
I suspect that the Power Automate team will eventually give us an expression to find the difference between two dates. Until then, use the technique outlined above.