Time between date excel

Use the DATEDIF function when you want to calculate the difference between two dates. First put a start date in a cell, and an end date in another. Then type a formula like one of the following.

Warning: If the Start_date is greater than the End_date, the result will be #NUM!.

Difference in days

=DATEDIF(D9,E9,"d") with result of 856

In this example, the start date is in cell D9, and the end date is in E9. The formula is in F9. The “d” returns the number of full days between the two dates.

Difference in weeks

=(DATEDIF(D13,E13,"d")/7) and result: 122.29

In this example, the start date is in cell D13, and the end date is in E13. The “d” returns the number of days. But notice the /7 at the end. That divides the number of days by 7, since there are 7 days in a week. Note that this result also needs to be formatted as a number. Press CTRL + 1. Then click Number > Decimal places: 2.

Difference in months

=DATEDIF(D5,E5,"m") and result: 28

In this example, the start date is in cell D5, and the end date is in E5. In the formula, the “m” returns the number of full months between the two days.

Difference in years

=DATEDIF(D2,E2,"y") and result: 2

In this example, the start date is in cell D2, and the end date is in E2. The “y” returns the number of full years between the two days.

Calculate age in accumulated years, months, and days

You can also calculate age or someone’s time of service. The result can be something like “2 years, 4 months, 5 days.”

1. Use DATEDIF to find the total years.

=DATEDIF(D17,E17,"y") and result: 2

In this example, the start date is in cell D17, and the end date is in E17. In the formula, the “y” returns the number of full years between the two days.

2. Use DATEDIF again with “ym” to find months.

=DATEDIF(D17,E17,"ym") and result: 4

In another cell, use the DATEDIF formula with the “ym” parameter. The “ym” returns the number of remaining months past the last full year.

3. Use a different formula to find days.

=DATEDIF(D17,E17,"md") and result: 5

Now we need to find the number of remaining days. We’ll do this by writing a different kind of formula, shown above. This formula subtracts the first day of the ending month (5/1/2016) from the original end date in cell E17 (5/6/2016). Here’s how it does this: First the DATE function creates the date, 5/1/2016. It creates it using the year in cell E17, and the month in cell E17. Then the 1 represents the first day of that month. The result for the DATE function is 5/1/2016. Then, we subtract that from the original end date in cell E17, which is 5/6/2016. 5/6/2016 minus 5/1/2016 is 5 days.

Warning: We don’t recommend using the DATEDIF «md» argument because it may calculate inaccurate results.

4. Optional: Combine three formulas in one.

=DATEDIF(D17,E17,"y")&" years, "&DATEDIF(D17,E17,"ym")&" months, "&DATEDIF(D17,E17,"md")&" days" and result: 2 years, 4 months, 5 days

You can put all three calculations in one cell like this example. Use ampersands, quotes, and text. It’s a longer formula to type, but at least it’s all in one. Tip: Press ALT+ENTER to put line breaks in your formula. This makes it easier to read. Also, press CTRL+SHIFT+U if you can’t see the whole formula.

Download our examples

Other date and time calculations

As you saw above, the DATEDIF function calculates the difference between a start date and an end date. However, instead of typing specific dates, you can also use the TODAY() function inside the formula. When you use the TODAY() function, Excel uses your computer’s current date for the date. Keep in mind this will change when the file is opened again on a future day.

=DATEDIF(TODAY(),D28,"y") and result: 984

Please note that at the time of this writing, the day was October 6, 2016.

Use the NETWORKDAYS.INTL function when you want to calculate the number of workdays between two dates. You can also have it exclude weekends and holidays too.

Before you begin: Decide if you want to exclude holiday dates. If you do, type a list of holiday dates in a separate area or sheet. Put each holiday date in its own cell. Then select those cells, select Formulas > Define Name. Name the range MyHolidays, and click OK. Then create the formula using the steps below.

1. Type a start date and an end date.

Start date in cell D53 is 1/1/2016, end date is in cell E53 is 12/31/2016

In this example, the start date is in cell D53 and the end date is in cell E53.

2. In another cell, type a formula like this:

=NETWORKDAYS.INTL(D53,E53,1) and result: 261

Type a formula like the above example. The 1 in the formula establishes Saturdays and Sundays as weekend days, and excludes them from the total.

Note: Excel 2007 doesn’t have the NETWORKDAYS.INTL function. However, it does have NETWORKDAYS. The above example would be like this in Excel 2007: =NETWORKDAYS(D53,E53). You don’t specify the 1 because NETWORKDAYS assumes the weekend is on Saturday and Sunday.

3. If necessary, change the 1.

Intellisense list showing 2 - Sunday, Monday; 3 - Monday, Tuesday, and so on

If Saturday and Sunday are not your weekend days, then change the 1 to another number from the IntelliSense list. For example, 2 establishes Sundays and Mondays as weekend days.

If you are using Excel 2007, skip this step. Excel 2007’s NETWORKDAYS function always assumes the weekend is on Saturday and Sunday.

4. Type the holiday range name.

=NETWORKDAYS.INTL(D53,E53,1,MyHolidays) and result: 252

If you created a holiday range name in the “Before you begin” section above, then type it at the end like this. If you don’t have holidays, you can leave the comma and MyHolidays out. If you are using Excel 2007, the above example would be this instead: =NETWORKDAYS(D53,E53,MyHolidays).

Tip: If you don’t want to reference a holiday range name, you can also type a range instead, like D35:E:39. Or, you could type each holiday inside the formula. For example if your holidays were on January 1 and 2 of 2016, you’d type them like this: =NETWORKDAYS.INTL(D53,E53,1,{«1/1/2016″,»1/2/2016»}). In Excel 2007, it would look like this: =NETWORKDAYS(D53,E53,{«1/1/2016″,»1/2/2016»})

You can calculate elapsed time by subtracting one time from another. First put a start time in a cell, and an end time in another. Make sure to type a full time, including the hour, minutes, and a space before the AM or PM. Here’s how:

1. Type a start time and end time.

Start date/time of 7:15 AM, End date/time of 4:30 PM

In this example, the start time is in cell D80 and the end time is in E80. Make sure to type the hour, minute, and a space before the AM or PM.

2. Set the h:mm AM/PM format.

Format cells dialog box, Custom command, h:mm AM/PM type

Select both dates and press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Make sure to select Custom > h:mm AM/PM, if it isn’t already set.

3. Subtract the two times.

=E80-D80 and result: 9:15 AM

In another cell, subtract the start time cell from the end time cell.

4. Set the h:mm format.

Format Cells dialog, Custom command, h:mm type

Press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Choose Custom > h:mm so that the result excludes AM and PM.

To calculate the time between two dates and times, you can simply subtract one from the other. However, you must apply formatting to each cell to ensure that Excel returns the result you want.

1. Type two full dates and times.

Start date of 1/1/16 1:00 PM; End date of 1/2/16 2:00 PM

In one cell, type a full start date/time. And in another cell, type a full end date/time. Each cell should have a month, day, year, hour, minute, and a space before the AM or PM.

2. Set the 3/14/12 1:30 PM format.

Format Cells dialog, Date command, 3/14/12 1:30 PM type

Select both cells, and then press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Then select Date > 3/14/12 1:30 PM. This isn’t the date you’ll set, it’s just a sample of how the format will look. Note that in versions prior to Excel 2016, this format might have a different sample date like 3/14/01 1:30 PM.

3. Subtract the two.

=E84-D84 and result of 1.041666667

In another cell, subtract the start date/time from the end date/time. The result will probably look like a number and decimal. You’ll fix that in the next step.

4. Set the [h]:mm format.

Format Cells dialog, Custom command, [h]:mm type

Press CTRL + 1 (or Image of the MAC Command button icon + 1 on the Mac). Select Custom. In the Type box, type [h]:mm.

Related Topics

DATEDIF function

NETWORKDAYS.INTL function

NETWORKDAYS

More date and time functions

Calculate the difference between two times

Since dates and times are stored as numbers in the back end in Excel, you can easily use simple arithmetic operations and formulas on the date and time values.

For example, you can add two different time values or date values or you can calculate the time difference between two given dates/times.

In this tutorial, I will show you a couple of ways to perform calculations using time in Excel (such as calculating the time difference, adding or subtracting time, showing time in different formats, and doing a sum of time values)

How Excel Handles Date and Time?

As I mentioned, dates and times are stored as numbers in a cell in Excel. A whole number represents a complete day and the decimal part of a number would represent the part of the day (which can be converted into hours, minutes, and seconds values)

For example, the value 1 represents 01 Jan 1900 in Excel, which is the starting point from which Excel starts considering the dates.

So, 2 would mean 02 Jan 1990, 3 would mean 03 Jan 1900 and so on, and 44197 would mean 01 Jan 2021.

Note: Excel for Windows and Excel for Mac follow different starting dates. 1 in Excel for Windows would mean 1 Jan 1900 and 1 in Excel for Mac would mean 1 Jan 1904

If there are any digits after a decimal point in these numbers, Excel would consider those as part of the day and it can be converted into hours, minutes, and seconds.

For example, 44197.5 would mean 01 Jan 2021 12:00:00 PM.

Date and Time and its equivalent Numeric value

So if you’re working with time values in Excel, you would essentially be working with the decimal portion of a number.

And Excel gives you the flexibility to convert that decimal portion into different formats such as hours only, minutes only, seconds only, or a combination of hours, minutes, and seconds

Now that you understand how time is stored in Excel, let’s have a look at some examples of how to calculate the time difference between two different dates or times in Excel

Formulas to Calculating Time Difference Between Two Times

In many cases, all you want to do is find out the total time that has elapsed between the two-time values (such as in the case of a timesheet that has the In-time and the Out-time).

The method you choose would depend on how the time is mentioned in a cell and in what format you want the result.

Let’s have a look at a couple of examples

Simple Subtraction of Calculate Time Difference in Excel

Since time is stored as a number in Excel, find the difference between 2 time values, you can easily subtract the start time from the end time.

End Time – Start Time

The result of the subtraction would also be a decimal value that would represent the time that has elapsed between the two time-values.

Below is an example where I have the start and the end time and I have calculated the time difference with a simple subtraction.

Calculate time Difference with subtraction

There is a possibility that your results are shown in the time format (instead of decimals or in hours/minutes values). In our above example, the result in cell C2 shows 09:30 AM instead of 9.5.

That’s perfectly fine as Excel tries to copy the format from the adjacent column.

To convert this into a decimal, change the format of the cells to General (the option is in the Home tab in the Numbers group)

Once you have the result, you can format it in different ways. For example, you can show the value in hours only or minutes only or a combination of hours, minutes, and seconds.

Below are the different formats you can use:

Format What it Does
h Shows only the hours elapsed between the two dates
hh Shows hours in double-digit (such as 04 or 12)
hh:mm Shows hours and minutes elapsed between the two dates, such as 10:20
hh:mm:ss  Shows hours, minutes, and seconds elapsed between the two dates, such as 10:20:36

And if you’re wondering where and how to apply these custom date formats, follow the below steps:

  1. Select the cells where you want to apply the date format
  2. Hold the Control key and press the 1 key (or Command + 1 if using Mac)
  3. In the Format Cells dialog box that opens, click on the Number tab (if not selected already)Click the Number group
  4. In the left pane, click on CustomClick on Custom option in Format Cells dialog box
  5. Enter any of the desired format code in the Type field (in this example, I am using hh:mm:ss)Enter the code to show hour minutes and seconds
  6. Click OK

The above steps would change the formatting and show you the value based on the format.

Result of time difference calculation

Note that custom number formatting does not change the value in the cell. It only changes the way a value is being displayed. So, I can choose to only show the hour value in a cell, while it would still have the original value.

Pro tip: If the total number of hours exceeds 24 hours, use the following custom number format instead: [hh]:mm:ss

Calculate the Time Difference in Hours, Minutes, or Seconds

When you subtract the time values, Excel returns a decimal number that represents the resulting time difference.

Since every whole number represents one day, the decimal part of the number would represent that much part of the day which can easily be converted into hours or minutes, or seconds.

Calculating Time Difference in Hours

Suppose you have the dataset as shown below and you want to calculate the number of hours between the two-time values

Time difference where we need to calculate hours

Below is the formula that will give you the time difference in hours:

=(B2-A2)*24
Time difference in houts

The above formula will give you the total number of hours elapsed between the two-time values.

Sometimes, Excel tries to be helpful and will give you the result in time format as well (as shown below).

Time difference shown in the time format only

You can easily convert this into Number format by clicking on the Home tab, and in the Number group, selecting Number as the format.

Click the Number option in the format drop down

If you only want to return the total number of hours elapsed between the two times (without any decimal part), use the below formula:

=INT((B2-A2)*24)
Calculating hours elapsed between two times

Note: This formula only works when both the time values are of the same day. If the day changes (where one of the time values is of another date and the second one of another date), This formula will give wrong results. Have a look at the section where I cover the formula to calculate the time difference when the date changes later in this tutorial.

Calculating Time Difference in Minutes

To calculate the time difference in minutes, you need to multiply the resulting value by the total number of minutes in a day (which is 1440 or 24*60).

Suppose you have a data set as shown below and you want to calculate the total number of minutes elapsed between the start and the end date.

Time difference where we need to calculate hours

Below is the formula that will do that:

=(B2-A2)*24*60
Calculate Time difference in Minutes

Calculating Time Difference in Seconds

To calculate the time difference in seconds, you need to multiply the resulting value by the total number of seconds in a day (which is or 24*60*60 or 86400).

Suppose you have a data set as shown below and you want to calculate the total number of seconds that have elapsed between the start and end date.

Time difference where we need to calculate hours

Below is the formula that will do that:

=(B2-A2)*24*60*60
Calculate Time difference in seconds

Calculating time difference with the TEXT function

Another easy way to quickly get the time difference without worrying about changing the format is to use the TEXT function.

The TEXT function allows you to specify the format right within the formula.

=TEXT(End Date - Start Date, Format)

The first argument is the calculation you want to do, and the second argument is the format in which you want to show the result of the calculation.

Suppose you have a dataset as shown below and you want to calculate the time difference between the two times.

Time difference where we need to calculate hours

Here are some formulas that will give you the result with different formats

Show only the number of hours:

=TEXT(B2-A2,"hh")
Calculating Time in hours using TEXT Function

The above formula will only give you the result that shows the numbers of hours elapsed between the two-time values. If your result is 9 hours and 30 minutes, it will still show you 9 only.

Show the number of total minutes

=TEXT(B2-A2,"[mm]")
Calculating Time in Minutes using TEXT Function

Show the number of total seconds

=TEXT(B2-A2,"[ss]")
Calculating Time in Seconds using TEXT Function

Show Hours and Minutes

=TEXT(B2-A2,"[hh]:mm")
Time difference in hours and minutes

Show Hours, Minutes, and Seconds

=TEXT(B2-A2,"hh:mm:ss")
Time difference in hours minutes and Seconds

If you’re wondering what’s the difference between hh and [hh] in the format (or mm and [mm]), when you use the square brackets, it would give you the total number of hours between the two dates, even if the hour value is higher than 24. So if you subtract two date values where the difference is more than24 hours, using [hh] will give you the total number of hours and hh will only give you the hours elapsed on the day of the end date.

Get the Time Difference in One-Unit (Hours/Minutes) and Ignore Others

If you want to calculate the time difference between the two time-values in only the number of hours or minutes or seconds, then you can use the dedicated HOUR, MINUTE, or SECOND function.

Each of these functions takes one single argument, which is the time value, and returns the specified time unit.

Suppose you have a data set as shown below, and you want to calculate the total number of hours minutes, and seconds that have elapsed between these two times.

In and Out time dataset

Below are the formulas to do this:

Calculating Hours Elapsed Between two times

=HOUR(B2-A2)
HOUR formula

Calculating Minutes from the time value result (excluding the completed hours)

=MINUTE(B2-A2)
Minute formula

Calculating Seconds from the time value result (excluding the completed hours and minutes)

=SECOND(B2-A2)
Second formula

A couple of things that you need to know when working with these HOURS, MINUTE, and SECOND formulas:

  • The difference between the end time and the start time cannot be negative (which is often the case when the date changes). In such cases, these formulas would return a #NUM! error
  • These formulas only use the time portion of the resulting time value (and ignore the day portion). So if the difference in the end time and the start time is 2 Days, 10 Hours, 32 Minutes, and 44 Seconds, the HOUR formula will give 10, the MINUTE formula will give 32, and the SECOND formula will give 44

Calculate elapsed time Till Now (from the start time)

If you want to calculate the total time that has elapsed between the start time and the current time, you can use the NOW formula instead of the End time.

NOW function returns the current date and the time in the cell in which it is used. It’s one of those functions that does not take any input argument.

So, if you want to calculate the total time that has elapsed between the start time and the current time, you can use the below formula:

=NOW() - Start Time

Below is an example where I have the start times in column A, and the time elapsed till now in column B.

Calculating time elapsed till now

If the difference in time between the start date and time and the current time is more than 24 hours, then you can format the result to show the day as well as the time portion.

You can do that by using the below TEXT formula:

=TEXT(NOW()-A2,"dd hh:ss:mm")

You can also achieve the same thing by changing the custom formatting of the cell (as covered earlier in this tutorial) so that it shows the day as well as the time portion.

In case your start time only has the time portion, then Excel would consider it as the time on 1st January 1990.

In this case, if you use the NOW function to calculate the time elapsed till now, it is going to give you the wrong result (as the resulting value would also have the total days that have elapsed since 1st Jan 1990).

In such a case, you can use the below formula:

=NOW()- INT(NOW())-A2

The above formula uses the INT function to remove the day portion from the value returned by the now function, and this is then used to calculate the time difference.

Note that NOW is a volatile function that updates whenever there is a change in the worksheet, but it does not update in real-time

Calculate Time When Date Changes (calculate and display negative times in Excel)

The methods covered so far work well if your end time is later than the start time.

But the problem arises when your end time is lower than the start time. This often happens when you are filling timesheets where you only enter the time and not the entire date and time.

In such cases, if you’re working in a one night shift and the date changes, there is a possibility that your end time would be earlier than your start time.

For example, if you start your work at 6:00 PM in the evening, and complete your work & time out at 9:00 AM in the morning.

If you only working with time values, then subtracting the start time from the end time is going to give you a negative value of 9 hours (9 – 18).

And Excel cannot handle negative time values (and for that matter nor can humans, unless you can time travel)

In such cases, you need a way to figure out that the day has changed and the calculation should be done accordingly.

Thankfully, there is a really easy fix for this.

Suppose you have a dataset as shown below, where I have the start time and the end time.

In and out time on different dates

As you would notice that sometimes the start time is in the evening and the end time is in the morning (which indicates that this was an overnight shift and the day has changed).

If I use the below formula to calculate the time difference, it will show me the hash signs in the cells where the result is a negative value (highlighted in yellow in the below image).

=B2-A2
Showing hash instead of time elapsed

Here is an IF formula that whether the time difference value is negative or not, and in case it is negative then it returns the right result

=IF((B2-A2)<0,1-(A2-B2),(B2-A2))
Formula to calculate time when date changes

While this works well in most cases, it still falls short in case the start time and the end time is more than 24 hours apart. For example, someone signs in at 9:00 AM on day 1 and sign-out at 11:00 AM on day 2.

Since this is more than 24 hours, there is no way to know whether the person has signed out after 2 hours or after 26 hours.

While the best way to tackle this would be to make sure that the entries include the date as well as the time, but if it’s just the time that you’re working with, then the above formula should take care of most of the issues (considering it’s unlikely for anyone to work for more than 24 hours)

Adding/ Subtracting Time in Excel

So far, we have seen examples where we had the start and the end time, and we needed to find the time difference.

Excel also allows you to easily add or subtract a fixed time value from the existing date and time value.

For example, let’s say you have a list of queued tasks where each task takes the specified time, and you want to know when each task will end.

In such a case, you can easily add the time that each task is going to take to the start time to know at what time is the task expected to be completed.

Since Excel stores date and time values as numbers, you have to ensure that the time you are trying to add abides by the format that Excel already follows.

For example, if you add 1 to a date in Excel, it is going to give you the next date. This is because 1 represents an entire day in Excel (which is equal to 24 hours).

So if you want to add 1 hour to an existing time value, you cannot go ahead and simply add 1 to it. you have to make sure that you convert that hour value into the decimal portion that represents one hour. and the same goes for adding minutes and seconds.

Using the TIME Function

Time function in Excel takes the hour value, the minute value, and the seconds value and converts it into a decimal number that represents this time.

For example, if I want to add 4 hours to an existing time, I can use the below formula:

=Start Time + TIME(4,0,0)
Adding time using the TIME function

This is useful if you know how many hours, minutes, and seconds you want to add to an existing time and simply use the TIME function without worrying about the correct conversion of the time into a decimal value.

Also, note that the TIME function will only consider the integer part of the hour, minute, and seconds value that you input. For example, if I use 5.5 hours in the TIME function it would only add five hours and ignore the decimal part.

Also, note that the TIME function can only add values that are less than 24 hours. If your hour value is more than 24, this would give you an incorrect result.

And the same goes with the minutes and the second’s part where the function will only consider values that are less than 60 minutes and 60 seconds

Just like I have added time using the TIME function, you can also subtract time. Just change the + sign to a negative sign in the above formulas

Using Basic Arithmetic

When the time function is easy and convenient to use, it does come with a few restrictions (as covered above).

If you want more control, you can use the arithmetic method that I’ll cover here.

The concept is simple – convert the time value into a decimal value that represents the portion of the day, and then you can add it to any time value in Excel.

For example, if you want to add 24 hours to an existing time value, you can use the below formula:

=Start_time + 24/24

This just means that I’m adding one day to the existing time value.

Now taking the same concept forward let’s say you want to add 30 hours to a time value, you can use the below formula:

=Start_time + 30/24

The above formula does the same thing, where the integer part of the (30/24) would represent the total number of days in the time that you want to add, and the decimal part would represent the hours/minutes/seconds

Similarly, if you have a specific number of minutes that you want to add to a time value then you can use the below formula:

=Start_time + (Minutes to Add)/24*60

And if you have the number of seconds that you want to add, then you can use the below formula:

=Start_time + (Minutes to Add)/24*60*60

While this method is not as easy as using the time function, I find it a lot better because it works in all situations and follows the same concept. unlike the time function, you don’t have to worry about whether the time that you want to add is less than 24 hours or more than 24 hours

You can follow the same concept while subtracting time as well. Just change the + to a negative sign in the formulas above

How to SUM time in Excel

Sometimes you may want to quickly add up all the time values in Excel. Adding multiple time values in Excel is quite straightforward (all it takes is a simple SUM formula)

But there are a few things you need to know when you add time in Excel, specifically the cell format that is going to show you the result.

Let’s have a look at an example.

Below I have a list of tasks along with the time each task will take in column B, and I want to quickly add these times and know the total time it is going to take for all these tasks.

Activity and time taken data

In cell B9, I have used a simple SUM formula to calculate the total time all these tasks are going to take, and it gives me the value as 18:30 (which means that it is going to take 18 hours and 20 minutes to complete all these tasks)

Sum of time where sum is less than 24 hours

All good so far!

How to SUM over 24 hours in Excel

Now see what happens when I change at the time it is going to take Task 2 to complete from 1 hour to 10 hours.

SUM formula giving incorrect time value

The result now says 03:20, which means that it should take 3 hours and 20 minutes to complete all these tasks.

This is incorrect (obviously)

The problem here is not Excel messing up. The problem here is that the cell is formatted in such a way that it will only show you the time portion of the resulting value.

And since the resulting value here is more than 24 hours, Excel decided to convert the 24 hours part into a day remove it from the value that is shown to the user, and only display the remaining hours, minutes, and seconds.

This, thankfully, has an easy fix.

All you need to do is change the cell format to force it to show hours even if it exceeds 24 hours.

Below are some formats that you can use:

Format Expected Result
[h]:mm 28:30
[m]:ss 1710:00
d “D” hh:mm 1 D 04:30
d “D” hh “Min” ss “Sec” 1 D 04 Min 00 Sec
d “Day” hh “Minute” ss “Seconds” 1 Day 04 Minute 00 Seconds

You can change the format by going to the format cells dialog box and applying the custom format, or use the TEXT function and use any of the above formats in the formula itself

You can use the below the TEXT formula to show the time, even when it’s more than 24 hours:

=TEXT(SUM(B2:B7),"[h]:mm:ss")
TEXT formula to show hours when more than 24

or the below formula if you want to convert the hours exceeding 24 hours to days:

=TEXT(SUM(B2:B7),"dd hh:mm:ss")
TEXT formula to show days in the time result

Results Showing Hash (###) Instead of Date/Time (Reasons + Fix)

In some cases, you may find that instead of showing you the time value, Excel is displaying the hash symbols in the cell.

Here are some possible reasons and the ways to fix these:

The column is not wide enough

When a cell doesn’t have enough space to show the complete date, it may show the hash symbols.

It has an easy fix – change the column width and make it wider.

Negative Date Value

A date or time value cannot be negative in Excel. in case you are calculating the time difference and it turns out to be negative, Excel will show you hash symbols.

The way to fixes to change the formula to give you the right result. For example, if you are calculating the time difference between the two times, and the date changes, you need to adjust the formula to account for it.

In other cases, you may use the ABS function to convert the negative time value into a positive number so that it’s displayed correctly. Alternatively, you can also an IF formula to check if the result is a negative value and return something more meaningful.

In this tutorial, I covered topics about calculating time in Excel (where you can calculate the time difference, add or subtract time, show time in different formats, and sum time values)

I hope you found this tutorial useful.

Other Excel tutorials you may also like:

  • Convert Time to Decimal Number in Excel (Hours, Minutes, Seconds)
  • How to Remove Time from Date/Timestamp in Excel
  • How to Calculate the Number of Days Between Two Dates in Excel
  • Combine Date and Time in Excel
  • How to Calculate Years of Service in Excel
  • How to Convert Seconds to Minutes in Excel

47

While working with time and dates in excel, you frequently get the need to calculate hours, minutes and seconds between two timestamps.

Well, in excel 2016 calculating the time difference is quite easy. You just need to subtract the start time from the end time.

Let’s Do It With An Example

You are assigned five tasks. You enter the start time of a task whenever you start it.

48

In the next column you have NOW() function of Excel is running that give. NOW() in excel is used to calculate the current time.

In the next column, you want to calculate the minutes passed since you started that task, as shown in the above image.

The Generic Formula to calculate the minutes between two times is:

(END TIME — START TIME)*1440

We subtract time/dates in excel to get the number of days. Since a day has 1440 (24*60) minutes, we multiply the result by 1440 to get the exact number of minutes.

For this example, we write the formula below in cell D2 and copy it in the cells below:

49

So, we cleared our doubts about how to calculate time in excel 2016. This can be done in all versions of Excel including excel 2013, Excel 2010, Excel 2007, and even older versions

Related Articles:

Get days between dates in Excel

Calculate years between dates

How to Add Years to a Date

Calculate Minutes Between Dates & Time In Microsoft Excel

Calculate hours between time in Excel

Multiplying time values and numbers

Calculate age from date of birth

Popular Articles:

50 Excel Shortcut to Increase Your Productivity

The VLOOKUP Function in Excel

COUNTIF in Excel 2016

How to Use SUMIF Function in Excel

Recently I was asked how to subtract time in Excel (time difference) or how to calculate the number of hours between two points in time on different days. Since this was in a reader comment, I gave a brief answer that requires a fuller account here.

Dates and Times are all part of the master plan in Excel. Once you “get” the fundamentals, the rest is just icing on the cake.

A Date value in Excel looks like this: 40519
A Time value in Excel looks like this: 0.58333

Cell formatting changes how you see these numbers.

The Date: 7 Dec, 2010
The Time: 2:00 PM

How to Calculate Time Between Dates in Excel or the Duration Between Two Dates

If you want to calculate time between dates in Excel or the duration between two dates, you need to understand what they mean first. When you type a Date into Excel, you may never see the underlying number, like 40519, but it’s there nonetheless. This is a date serial number and it makes Date calculations easy.

You might ask, “Why is this such a weird-looking number?”. Well, the Excel folks started a numbering system with Dates. In Excel for Windows they gave 1 Jan, 1900 the serial date number of 1, then continued numbering until this day and beyond. So serial number 40519 represents 7 Dec, 2010.

In Excel for Mac they started numbering Dates beginning with 2 Jan, 1904. (don’t ask) So the serial date 40519 represents 8 Dec, 2014 (Actually it’s known as the 1904 date system. To be clear, Macs can change Excel settings to use the 1900 date system).

How to Subtract Time in Excel (Time Difference)

When you type 2:00 PM into a cell in Excel the underlying value is a fraction, but Excel interprets this as a time serial number and formats the cell accordingly.

Try typing 0.25 into a blank cell, then change the cell formatting to a TIME format, and you’ll get something like 6:00 AM.

As an aside, you can calculate this fraction for any time value during the day by taking the total number of seconds that have passed from midnight until your time value and dividing by 86,400 seconds in a day.

Image of an equation to calculate time difference

Dates and Times Together

In Excel the unit of time is “the Day,” a key fact to know. You’ll notice that Dates are integers, and Time is a fractional number. You can add the two together to get a Date/Time format.

So adding a Date serial number, like 40518, to a Time serial number, like 0.25, gives us 40518.25. Formatting the cell holding this value using “d mmm, yyyy h:mm AM/PM” will show 6 Dec, 2010 6:00 AM.

You can also enter something like 7 Dec, 2010 2:00 PM into a cell and Excel will recognize this as a Date/Time format. However, if you change the cell formatting to General, the underlying number is 40519.05833.

So hopefully by now you can see that subtracting two Date/Time formatted numbers can be done mathematically. Subtracting 6 Dec, 2010 6:00 AM from 7 Dec, 2010 2:00 PM is done by Excel “underneath the hood” as 40519.05833 – 40518.25 and the result is 1.3333.

Calculating Hours Between Two Dates in Excel

If we recall that the unit of time is “the Day,” this value represents 1-1/3 days of time.  Since there are 24 hours in a day, converting to hours is a simple multiplication 24 * 1.3333 = or 32 hours. (24 * 4/3 to be more precise)

Time Between Two Times / Dates

Finding the number of hours or the time between two times/dates is simple, just subtract the start date/time from the end date/time and multiply the result by 24 hours.

If you want to enter the dates and times separately (which is loads easier than typing in a date/time in one cell) then add the date/times together.

Hours = ((End_Date+End_Time)-(Start_Date+Start_Time))*24

Here’s a look at a typical worksheet designed to calculate the hours between two dates.

Image of an Excel table with dates and times

As you can see, the formula for Hours, in cell F2, shows in the formula bar. And row 3 contains General formatting so you can view the date/time serial numbers for row 2.

Change the formatting for cells B2:E2 to match what you normally use for Date and Time data entry.

The NETWORKDAYS Function

People also asked how to calculate the time between days but without taking into account weekends or specified holidays. The NETWORKDAYS function will help you to calculate the time period by excluding weekdays and specified holidays.

The formula looks like this: =NETWORKDAYS(start_dateend_date, [holidays])

Like in the previous case the start_date and end_date are required arguments, yet the argument [holidays] is optional. You can use this argument to specify which days should be excluded.

Image of an Excel list showing NETWORKDAYS formula

This time I used two random dates which contained two weekends and I added two desired dates under the holidays argument just to show you how it works.

If you need to add some weekends you will have to add one more argument (weekends) and use =NETWORKDAYS.INTL(start_dateend_date[weekend][holidays])

After you calculated the days by using the NETWORKDAYS formula, to calculate the hours you can simply multiply the given number with the number of hours you need for as long as they stay the same.  Also, do not work harder by looking for complicated formulas to calculate simple things.

What else you should know:

  • If the start date is later than the end date the formula will generate a negative number.
  • The NETWORKDAYS formula will also include the start and the ending dates in the calculations, due to this if you have the same date the value returned will be 1.

If you want to find more formulas regarding the date and time feel free to check the following list of functions.

I hope this article helps you to better understand how to calculate hours between two dates in Excel. You can exercise what you learned today by calculating the time left until your next birthday, to do this you can also use the =Today function or the =Now function.

If you found this article helpful, please feel free to check our other articles about tips and tricks in Excel. We also have a dedicated section for details and formulas about dates and times in Excel.

Related Posts Plugin for WordPress, Blogger...

I am doing some work in Excel and am running into a bit of a problem. The instruments I am working with save the date and the time of the measurements and I can read this data into Excel with the following format:

   A           B
1 Date:      Time:
2 12/11/12   2:36:25
3 12/12/12   1:46:14

What I am looking to do is find the difference in the two date/time stamps in mins so that I can create a decay curve from the data. So In Excel, I am looking to Make this (if the number of mins in this example is wrong I just calculated it by hand quickly):

   A           B                 C
1 Date:      Time:       Time Elapsed (Minutes)
2 12/11/12   2:36:25               -
3 12/12/12   1:46:14            1436.82

I Have looked around for a bit and found several methods for the difference in time but they always assume that the dates are the same. I exaggerated the time between my measurements some but that roll over of days is what is causing me grief. Any suggestions or hints as to how to go about this would be great. Even If I could find the difference between the date and times in hrs or days in a decimal format, I could just multiple by a constant to get my answer. Please note, I do have experience with programming and Excel but please explain in details. I sometimes get lost in steps.

Kara's user avatar

Kara

6,08516 gold badges51 silver badges57 bronze badges

asked Dec 11, 2012 at 7:28

Linux Rules's user avatar

1

time and date are both stored as numerical, decimal values (floating point actually). Dates are the whole numbers and time is the decimal part (1/24 = 1 hour, 1/24*1/60 is one minute etc…)

Date-time difference is calculated as:

date2-date1

time2-time1

which will give you the answer in days, now multiply by 24 (hours in day) and then by 60 (minutes in hour) and you are there:

time elapsed = ((date2-date1) + (time2-time1)) * 24 * 60

or

C3 = ((A3-A2)+(B3-B2))*24*60

Liam's user avatar

Liam

27k27 gold badges123 silver badges185 bronze badges

answered Dec 11, 2012 at 7:39

K_B's user avatar

K_BK_B

3,6681 gold badge18 silver badges29 bronze badges

4

Neat way to do this is:

=MOD(end-start,1)*24

where start and end are formatted as «09:00» and «17:00»

Midnight shift
If start and end time are on the same day the MOD function does not affect anything. If the end time crosses midnight, and the end is earlier then start (say you start 23PM and finish 1AM, so result is 2 hours), the MOD function flips the sign of the difference.

Note that this formula calculates the difference between two times (actually two dates) as decimal value. If you want to see the result as time, display the result as time (ctrl+shift+2).

https://exceljet.net/formula/time-difference-in-hours-as-decimal-value

answered Jan 8, 2019 at 13:55

Przemyslaw Remin's user avatar

Przemyslaw ReminPrzemyslaw Remin

6,09624 gold badges108 silver badges186 bronze badges

  1. get n day between two dates, by using days360 function =days360(dateA,dateB)
  2. find minute with this formula using timeA as reference =(timeB-$timeA+n*»24:00″)*1440
  3. voila you get minutes between two time and dates

answered Jun 21, 2019 at 1:09

riadhifrz's user avatar

I think =TEXT(<cellA> - <cellB>; "[h]:mm:ss") is a more concise answer. This way, you can have your column as a datetime.

answered Dec 22, 2014 at 10:27

Igbanam's user avatar

IgbanamIgbanam

5,8615 gold badges43 silver badges68 bronze badges

1

Понравилась статья? Поделить с друзьями:
  • Time and travel word problems
  • Time and the word lyrics
  • Time and place in a sentence for each word
  • Time and dates in excel
  • Time and date word problems