While experimenting with Power Automate Date, I had to determine the date and time difference between two timestamps. In that case, I have used the Power Automate dateDifference() function.
This complete tutorial will let you understand what the dateDifference() function in Power Automate, its syntax, and how to use it with various formats like:
- Working with Power Automate dateDifference() in days
- How to use Power Automate dateDifference() in hours
- Working with Power Automate dateDifference() in minutes and seconds
Power Automate dateDifference() Function
Power Automate dateDifference() calculates the time difference between two timestamps by subtracting the start date from the end date instead of the ticks() function. The result of the function is then returned as a timestamp in string format.
This dateDifference() function can extract the difference in formats like Days, Hours, Minutes, and Seconds.
The output will also be in the form of a string containing the evaluating timestamp.

This is a brief introduction to the Power Automate dateDifference() function.
Power Automate dateDifference() Function Syntax
The syntax of the dateDifference() function in Power Automate is:
dateDifference('startDate','endDate')Parameters:
- Start date: It is a required field where the string contains the timestamp.
- End date: It is also a required field with type as a string containing a timestamp.
Example:
dateDifference('01-11-2023','08-12-2023')Where,
- 01-11-2023 = Provide the required start date.
- 08-12-2023 = Give the required end date.
The output will be 37.00:00:00[days].
If the start date is newer than the end date, it will give the result a negative value.
Output of dateDifference Format: days.hours:minutes:secondsThis is about Power Automate dateDifference() function syntax in a flow.
Power Automate dateDifference() in Days
Here, I will explain how to use the dateDifference() function in Power Automate by implementing it in a manual trigger flow of Power Automate.
Example:
Let’s take the start date as “13-12-2023″ and the end date as “15-12-2023.” We want to extract the difference between these dates in days. The result will give a difference of 2 days.

For that, follow the below-mentioned steps to create a flow that will work with the dateDifference() function:
1. To access the Power Automate Home page, launch your browser and type in make.powerautomate.com to log in with your Microsoft credentials.
Instructions: In the Power Automate Home page, click on +Create -> Select Instant cloud flow ->Then, set Flow name -> Choose Manually trigger a flow -> Click on Create -> In the trigger, select Date input.

2. Next, include an Initialize variable flow action to retain a specified date or timestamp value throughout the flow. Set the variable’s properties:
- Name: Enter the variable name manually as the End date.
- Type: Select the type of a variable as String.
- Value: Select field -> Click Expression -> Add the expression given in the code.
utcNow('yyyy-MM-ddTHH:MM')Then, Click OK.
Alternatively, you can specify a specific date from which the difference can be calculated.

3. In this step, add a Compose flow action to express dateDifference() in the Inputs section.
- Inputs: Select the field -> Click on Expression -> Place the below code.
dateDifference(triggerBody()['date'],variables('End date'))After that, click OK.

4. To extract the part of the result in days, use the split() expression by taking another compose flow action.
- Inputs: Select the field -> Click on Expression -> Take the code below.
split(outputs('Compose'),'.')[0]Select OK.

5. The Power Automate flow is ready to Save now. After saving, Test the flow manually. In the Run flow box, pick a date you need to trigger for the start date.
- The triggered date I will take here is 2023-12-13, and Today’s date is 2023-12-15.
Then, Click Run flow.

6. After running successfully, open a compose flow action to see the difference between the dates in the day format.
- The return value in the form of days will be 2 days.

This is how to extract the date difference in days from the Power Automate dateDifference() function.
Power Automate dateDifference() in Hours
So, similarly, let’s see how to extract the Power Automate dateDifference() function in hours.
Example:
Given a start date of “07-11-2023” and an end date of the current date, i.e.”15-12-2023,” we need to extract the result of the dateDifference() in hours.
The output format of dateDifference() is days: hours: minutes: seconds[38.14:12:00]. To obtain the result in hours, we need to extract the hours section from the output, which should be 14 hours.

Follow the same steps to calculate the difference between the two dates.
1. In the Compose flow action, add the split() function to extract hours from the output of dateDifference().
- Inputs: Select the field -> Click on Expression -> Take the code below.
Inputs: split(split(outputs('Compose'),'.')[1],':')[0]
After the expression, Click OK.
2. The image represents the difference between two dates in the format like [day. hours: minutes: seconds] in the compose flow action outputs.

3. When the flow runs successfully, check out the composed flow action inputs to see if the output will only be extracted in hours[14], as shown below.
- The result will take 14 hours from the dateDifference() format.

This is how to extract the Power Automate dateDifference() function in hours between a start date and the end date.
Power Automate dateDifference() in Minutes
Now, let us see how to calculate the date difference between dates and extract the minute intervals from the output.
Example
In this example, let us assume the start date is “07-11-2023,” and the end date will be the current date, i.e., “15-12-2023.” We need to extract the result of the dateDifference() in Minutes.
The dateDifference() function returns the result as 38.14:12:00 [days. Hours: Minutes: seconds]. We wanted to extract the minutes section from the output, which is 12 minutes.

To achieve this, follow the above steps mentioned in the above example.
1. To provide a split() expression and the variable of date difference outputs, you can add the Compose action.
- Inputs: Select the field -> Click on Expression -> Insert the code below.
Inputs: int(split(split(dateDifference(triggerBody()['date'],variables('End date')), '.')[1], ':')[1])
2. Access the compose flow action to review the split() expression output following the flow’s execution. You will notice that the results are now extracted in minute intervals.
- The result will get the minute[12] intervals of the output.

This is how to get Power Automate dateDifference() in minute intervals from the output.
Power Automate dateDifference() in Seconds
In seconds, let us dive into the final example, i.e., Power Automate dateDifference().
Example
Given a start date of “07-11-2023” and an end date of the current date, i.e., “15-12-2023,” we need to extract the result of the dateDifference() in second intervals.
The output format of dateDifference() between those dates is 38.06:12:42 [days. Hours:Minutes: Seconds]. Here, we need to extract the seconds interval from the output, i.e., 42 seconds.

Like above, follow the exact instructions, only change the expression of dateDifference and split in the compose flow action.
1. To extract the output of dateDifference() in seconds, add the split() function with the dateDifference in the ‘Compose‘ flow action.
Use the Power Automate int() function and the split() expression to get the result in an integer format.
Inputs: Select the field -> Click on Expression -> Insert the code below.
Inputs: int(split(split(dateDifference(triggerBody()['date'],variables('End date')), '.')[1], ':')[2])After giving the code, Click OK.

2. The image shows the variance between two dates in the format of [day.hours:minutes:seconds], as displayed in the output of the compose flow action.

3. The review of the composed flow action obtains the output duration in seconds once the flow runs successfully.
- The result will take seconds [42] intervals from the output.

This is how to use the Power Automate dateDifference() function to calculate the between two dates in various formats.
Moreover, you may like some more Power Automate articles:
- Power Automate addDays() Function
- Power Automate isInt() Function
- Power Automate toUpper() + toLower() Function
- Power Automate formatDateTime() Function
Conclusion
I hope you understand how to work with the Power Automate dateDifference() function to calculate and find the difference between two dates.
Additionally, we discussed some more topics below:
- How to work with Power Automate dateDifference() in days
- Use Power Automate dateDifference() in hours
- Working with Power Automate dateDifference() in minutes and seconds

Preeti Sahu is an expert in Power Apps and has over six years of experience working with SharePoint Online and the Power Platform. She is the co-author of Microsoft Power Platform: A Deep Dive book. As a Power Platform developer, she has worked on developing various tools using Power Apps and Power Automate. She also makes Microsoft 365 videos and shares them on YouTube.