How to Calculate Days Between Dates in Power Apps?

When you’re building an app with Power Apps, one of the things you might need is to figure out how many days lie between two dates. Maybe you want to track how long a project will take, calculate the number of leave days someone is requesting, or manage the timeline for an event.

In this Power Apps tutorial, we will discuss how to Calculate Days Between Dates in Power Apps, calculate days between Start Date and End Date in Power Apps, and calculate Days between two dates using the Power Apps Text input control.

Also, I will tell you how to calculate days between dates, including Hours, Minutes, and seconds, in Power Apps with various examples.

Calculate Days Between Dates in Power Apps

Power Apps Calculate Days Between Dates means finding the number of days between two dates you select in the app. For example, if you choose a start date and an end date, Power Apps can help you quickly determine the total number of days between them. This is useful for things like tracking leave days, project durations, or event lengths.

So let’s get started!

How to Calculate Days Between Two Dates Using Power Apps Text input

In the image below, there are two Modern Text input controls where users can manually enter a Start Date and an End Date.

The right side label displays the total number of days between the Start and End dates.

Power Apps Calculate Days Between Two Dates

To achieve it, apply the code below to the Label’s Text property:

"Total no. of Days: " & DateDiff(
    txtStartDate.Value,
    txtEndDate.Value,
    TimeUnit.Days
)

OR

"Total no. of Days: " & DateDiff(
    DateTimeValue(txtStartDate.Value),
    DateTimeValue(txtEndDate.Value),
    TimeUnit.Days
)

Where,

  • txtStartDate, txtEndDate = Start Date & End Date Text inputs
PowerApps Calculate Days Between Two Dates

Save and preview the app. Enter a Start Date and End Date (with mm/dd/yyyy) format. Then the total number of days will be visible in the label.

Calculate Days Between Start Date and End Date in Power Apps

Let’s say you’re building a leave request app for your company. Employees select their start date and end date for their leave. You want to automatically calculate the number of days of leave they are requesting.

In that case, the employee picks the start and end dates using Modern Date Picker controls. Power Apps then calculates the number of days between those dates and shows the total leave days on the label, as shown below.

Power Apps Calculate Days Between Dates

To work around this, set the Label’s Text property to the code below:

"Total Number Of Days: " & DateDiff(
    dtStartDate.SelectedDate,
    dtEndDate.SelectedDate,
    TimeUnit.Days
) + 1

Where,

  • dtStartDate, dtEndDate = Modern Date Pickers for Start Date and End Date
Calculate Days Between Start Date and End Date in Power Apps

This way, we can calculate the days between the Start Date and End Date in Power Apps.

Calculate Days Between Dates (With Hours, Minutes, and Seconds) in Power Apps

Suppose you want to display the total number of Hours, Minutes, and Seconds between the two Date picker controls (Start Date and End Date) in some cases, as shown in the screenshot below:

Power Apps Calculate Days Between Dates With Hours, Minutes, and Seconds

To do this, apply the code below to the Label’s Text property as:

Concatenate(
    Text(
        DateDiff(
            dtStartDate.SelectedDate,
            dtEndDate.SelectedDate,
            TimeUnit.Hours
        )
    ),
    ":",
    Text(
        DateDiff(
            dtStartDate.SelectedDate,
            dtEndDate.SelectedDate,
            TimeUnit.Minutes
        )
    ),
    ":",
    Text(
        DateDiff(
            dtStartDate.SelectedDate,
            dtEndDate.SelectedDate,
            TimeUnit.Seconds
        )
    )
)

dtStartDate, dtEndDate = Date Pickers for Start and End Date

PowerApps Calculate Days Between Dates

Once you save and preview the app, you can view the result in the label control as shown above.

I hope this post helped you understand how to calculate days between dates in Power Apps—whether you’re using date pickers or text input controls. We also looked at how to calculate the difference including hours, minutes, and seconds for more precise timing. With these tips, you can easily add date calculations to your apps and make them more useful.

Also, you may like some more Power Apps tutorials:

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