How do i calculate the time between two dates in excel?

Most of the work in this formula is done by the TEXT function, which applies a custom number format for hours and minutes to a value created by subtracting the start date from the end date.

TEXT(C5-B5,"h"" hrs ""m"" mins """)

This is an example of embedding text into a custom number format, and this text must be surrounded by an extra pair of double quotes. Without the extra double quotes, the custom text format looks like this:

The value for days is calculated with the INT function, which simply returns the integer portion of the end date minus the start date:

INT(C5-B5) // get day value

Note: Although you can use "d" in a custom number format for days, the value will reset to zero when days is greater than 31.

Include seconds

To include seconds, you can extend the custom number format like this:

=INT(C5-B5)&" days "&TEXT(C5-B5,"h"" hrs ""m"" mins ""s"" secs""")

Total days, hours, and minutes between dates

To get the total days, hours, and minutes between a set of start and end dates, you can adapt the formula using SUMPRODUCT like this:

where "ends" represents the range of end dates, and "starts" represents the range of start dates. In the example shown, D11 contains this formula:

[ad-banner image=”https://www.bettercloud.com/wp-content/uploads/sites/3/2015/06/119clicks-250×260-1.jpg” url=”https://www.bettercloud.com/top-it-workflows-and-automations/?bc_offer=academy-monitor-119clicks-250X260″]

Calculating the amount of time between two dates is slightly more complicated than calculating the difference between other types of numbers. The irregular number of days in months, leap years, and other factors make this type of calculation slightly more complex. However, Microsoft Excel has a function you might not know about that’s designed specifically to calculate the amount of time in between two dates.

  1. In Microsoft Excel, list the dates you’d like to calculate the time between. For this example, let’s say cell A1 has one date, and B1 has another.
  2. In a new cell, type in =DATEDIF(A1,B1,”Y”). The “Y” signifies that you’d like the information reported in years. This will give you the number of years between the two dates.
  3. To find the number of months or days between two dates, type into a new cell: =DATEDIF(A1,B1,”M”) for months or =DATEDIF(A1,B1,”D”) for days. 

Click here to watch this video on YouTube.


We can use the DATEDIF() function to calculate the difference between two dates in Excel.

This function uses the following syntax:

=DATEDIF(Start_Date, End_Date, Metric)

where:

  • Start_Date: The start date
  • End_Date: The end date
  • Metric: The metric to calculate. Options include:
    • “d”: Days
    • “m”: Months
    • “y”: Years

It’s important to note that this function won’t automatically appear in Excel until you completely type =DATEDIF( into one of the cells. 

The following examples show how to use this function to calculate the difference between two dates in Excel.

Example 1: Difference in Days

The following image shows how to calculate the difference (in days) between two dates:

How do i calculate the time between two dates in excel?

This tells us that there are 1,127 full days between 1/1/2018 and 2/1/2021.

Example 2: Difference in Months

The following image shows how to calculate the difference (in months) between two dates:

How do i calculate the time between two dates in excel?

Example 3: Difference in Years

The following image shows how to calculate the difference (in years) between two dates:

How do i calculate the time between two dates in excel?

Example 4: Difference in Years & Months

The following image shows how to calculate the difference (in years and months) between two dates:

How do i calculate the time between two dates in excel?

You can find more Excel tutorials on this page.

Post navigation