Power Apps DateDiff() Function [With Various Examples]

When using Power Apps, you might need to find the time difference between two dates or times. This could include calculating hours and minutes, using text inputs, or figuring out working hours excluding weekends.

In this tutorial, I will discuss the Power Apps DateDiff() function, how to calculate the time difference in Power Apps, and many more topics like:

  • How to calculate time difference in hours in Power Apps
  • Power Apps calculate time difference in minutes
  • Calculate time difference in hours & minutes using Power Apps text inputs
  • Power Apps calculate working hours between two dates, excluding weekends

DateDiff() in Power Apps

Power Apps DateDiff() is a function that helps you find the difference between two dates or times. It tells you how much time is between a start date and an end date, and you can choose whether you want the difference in days, hours, minutes, or other units.

Power Apps DateDiff() Syntax:

DateDiff( StartDateTime, EndDateTime [, Units ] )
  • StartDateTime: The first date or time.
  • EndDateTime: The second date or time.
  • Units: The type of difference you want to calculate, like Days, Hours, Minutes, Seconds, etc.

How to Use Power Apps DateDiff() Function

Let’s say you want to find out how many days are between July 1, 2025, and July 10, 2025. You can use the code below on a Label’s Text property:

DateDiff(
    DateValue("2025-07-01"),
    DateValue("2025-07-10"),
    TimeUnit.Days
)

This will return 9, because there are 9 days between those two dates.

Rather than entering the start and end dates manually, we can use Date Picker controls to select them.

Power Apps DateDiff

Calculate Time Difference in Power Apps

Let’s see how to calculate and display the time differences in both hours and minutes using Power Apps Date pickers.

In the app, there are two Date Picker controls that allow the user to select a Start Date and an End Date. There are also four dropdowns for selecting the Start and End Hours and Minutes.

Now, I want to calculate the time difference between these two dates and times. You can see this in the screenshot below.

PowerApps calculate time difference

To achieve this, insert a Label control and apply the following formula on its Text property:

Text = DateDiff(
    DtStartDate.SelectedDate + Time(
        Value(DDHour1.Selected.Value),
        Value(DDMin1.Selected.Value),
        0
    ),
    DtEndDate.SelectedDate + Time(
        Value(DDHour2.Selected.Value),
        Value(DDMin2.Selected.Value),
        0
    ),
    TimeUnit.Hours
) & ":" & Mod(
    DateDiff(
        DtStartDate.SelectedDate + Time(
            Value(DDHour1.Selected.Value),
            Value(DDMin1.Selected.Value),
            0
        ),
        DtEndDate.SelectedDate + Time(
            Value(DDHour2.Selected.Value),
            Value(DDMin2.Selected.Value),
            0
        ),
        TimeUnit.Minutes
    ),
    60
)

Where,

  1. DateDiff = Power Apps DateDiff() is a type of function that returns the difference between two date/time values, and the output is a whole number of units.
  2. DtStartDate = Date picker control name for the Start Date
  3. DtEndDate = Date picker control name for the End Date
  4. DDHour1 = Dropdown Hour control name for the Start Date
  5. DDMin1 = Dropdown Minute control name for the Start Date
  6. DDHour2 = Dropdown Hour control name for the End Date
  7. DDMin2 = Dropdown Minute control name for the End Date
  8. TimeUnit.Hours = This function returns the hour component of a date and time value, ranging from 0 (12:00 AM) to 23 (11:00 PM).
  9. TimeUnit.Minutes = This function returns the minute component of a Date/Time value, ranging from 0 to 59.
Power Apps calculate time difference

Save and Preview the. Select the Start Date and End Date, including the Hour and Minute. Then, the time difference result will be shown in the label control.

Calculate Time Difference in Hours & Minutes in Power Apps

Next, we will calculate the time difference between hours and minutes.

Calculate Time Difference in Hours in Power Apps

In the screenshot below, you’ll see two-time fields, called Purchase Start Time and Purchase End Time, displayed in a Power Apps Edit form. These fields are single lines of text and come from a SharePoint list named Book Purchase Info.

Now, I want to calculate the difference in hours between the Purchase Start Time and Purchase End Time.

calculate time difference in Power Apps

To work around this, insert a Label control and apply the below code on its Text property as:

Text = "Result: " & DateDiff(
    DateTimeValue(DataCardValue10.Text),
    DateTimeValue(DataCardValue11.Text),
    TimeUnit.Hours
)

Where,

  1. Result: ” = It is a string that will display in the label control
  2. DateTimeValue = PowerApps DateTimeValue is a function that helps to convert a date and time string (for example, “December 19, 2021, 12:31 PM”) to a date/time value.
  3. DataCardValue10 = Purchase Start Time Data Card Name
  4. DataCardValue11 = Purchase End Time Data Card Name
calculate time difference in PowerApps

Save and preview the app. Enter the time (like 09:15) in both the time fields and the result (only Hours) in the label control.

Calculate Time Difference in Minutes in Power Apps

Next, we will calculate the time difference in only minutes between the Purchase Start Time and Purchase End Time fields.

To do so, select the label control and set its Text property to the code below:

Text = "Result: " & DateDiff(
    DateTimeValue(DataCardValue10.Text),
    DateTimeValue(DataCardValue11.Text),
    TimeUnit.Minutes
)

Refer to the screenshot below.

how to calculate time difference in PowerApps

Save and preview the app. Enter the time (like 16:15) in both fields, and you’ll see the result (in minutes) displayed in the label control.

Calculate Time Difference in Hours & Minutes Using Power Apps Text Input

In this example, I used just two text input fields and a label control in the app. When a user types the time into the two input fields, the result appears in the label control.

To do so, select the label control and set its Text property as: // For Hours Only

Text = DateDiff(
    DateTimeValue(TextInput1.Text),
    DateTimeValue(TextInput2.Text),
    TimeUnit.Hours
)

Where,

TextInput1, TextInput2 = Text input control names

how to calculate time difference in Power Apps

Save and preview the app. When you enter the time in both text fields, the result will be displayed in the label control, as shown in the above screenshot.

Similarly, if you want to calculate only the minutes, you can also use the Split function to achieve this. Apply the below code on the Label’s Text property: // For Minutes Only

DateDiff(
    Time(
        Value(
            First(
                Split(
                    txtStartMinute.Text,
                    ":"
                )
            ).Value
        ),
        Value(
            Last(
                Split(
                    txtStartMinute.Text,
                    ":"
                )
            ).Value
        ),
        0
    ),
    Time(
        Value(
            First(
                Split(
                    txtEndMinute.Text,
                    ":"
                )
            ).Value
        ),
        Value(
            Last(
                Split(
                    txtEndMinute.Text,
                    ":"
                )
            ).Value
        ),
        0
    ),
    TimeUnit.Minutes
) & " Minutes"

Where,

  • txtStartMinute = Text input name for start minute
  • txtEndMinute = Text input name for end minute

Refer to the screenshot below.

Power Apps Calculate Time Difference

This way, we can calculate the time difference in hours and minutes using the Power Apps text input values.

Calculate Working Hours Between Two Dates (Exclude Weekends) in Power Apps

To calculate working hours between two dates in Power Apps, excluding weekends (Saturday & Sunday), follow the instructions below:

Let’s assume a standard workday is 8 hours. I’ve added two Date Picker controls: Start Date and End Date. When a user picks a start and end date, the app calculates the total working hours between those dates, excluding weekends, as shown below.

Power Apps Calculate Working Hours Between Two Dates Exclude Weekends

To achieve this, paste the code below on a Label’s Text property:

With(
    {
        startDate: DateTimeValue(dtStartDate.SelectedDate),
        endDate: DateTimeValue(dtEndDate.SelectedDate),
        dailyHours: 8
    },
    With(
        {
            totalDays: DateDiff(
                startDate,
                endDate,
                TimeUnit.Days
            ) + 1,
            weekdays: CountIf(
                Sequence(
                    DateDiff(
                        startDate,
                        endDate,
                        TimeUnit.Days
                    ) + 1,
                    0,
                    1
                ),
                Weekday(
                    DateAdd(
                        startDate,
                        Value,
                        TimeUnit.Days
                    )
                ) <> 1 && Weekday(
                    DateAdd(
                        startDate,
                        Value,
                        TimeUnit.Days
                    )
                ) <> 7
            )
        },
        weekdays * dailyHours
    )
) & " Hours"

Where,

  1. Sequence(…) creates a list of days between start and end.
  2. Weekday(…) checks the day of the week.
    • 1 = Sunday, 7 = Saturday (U.S. format)
  3. We CountIf only on weekdays and multiply by 8 hours.

I hope this guide has helped you understand Power Apps DateDiff(), how to calculate time differences in Power Apps, whether it’s in hours and minutes, using text inputs, or finding working hours between dates that exclude weekends. Also, give them a try in your projects and see how easy it is to work with time in Power Apps!

Additionally, you may like some more Power Apps articles:

4 thoughts on “Power Apps DateDiff() Function [With Various Examples]”

Leave a Comment

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App