Add time
Suppose that you want to know how many hours and minutes it will take to complete two tasks. You estimate that the first task will take 6 hours and 45 minutes and the second task will take 9 hours and 30 minutes.
Here is one way to set this up in the a worksheet.
-
Enter 6:45 in cell B2, and enter 9:30 in cell B3.
-
In cell B4, enter =B2+B3 and then press Enter.
The result is 16:15—16 hours and 15 minutes—for the completion the two tasks.
Tip: You can also add up times by using the AutoSum function to sum numbers. Select cell B4, and then on the Home tab, choose AutoSum. The formula will look like this: =SUM(B2:B3). Press Enter to get the same result, 16 hours and 15 minutes.
Well, that was easy enough, but there’s an extra step if your hours add up to more than 24. You need to apply a special format to the formula result.
To add up more than 24 hours:
-
In cell B2 type 12:45, and in cell B3 type 15:30.
-
Type =B2+B3 in cell B4, and then press Enter.
The result is 4:15, which is not what you might expect. This is because the time for Task 2 is in 24-hour time. 15:30 is the same as 3:30.
-
To display the time as more than 24 hours, select cell B4.
-
On the Home tab, in the Cells group, choose Format, and then choose Format Cells.
-
In the Format Cells box, choose Custom in the Category list.
-
In the Type box, at the top of the list of formats, type [h]:mm;@ and then choose OK.
Take note of the colon after [h] and a semicolon after mm.
The result is 28 hours and 15 minutes. The format will be in the Type list the next time you need it.
Subtract time
Here’s another example: Let’s say that you and your friends know both your start and end times at a volunteer project, and want to know how much time you spent in total.
Follow these steps to get the elapsed time—which is the difference between two times.
-
In cell B2, enter the start time and include “a” for AM or “p” for PM. Then press Enter.
-
In cell C2, enter the end time, including “a” or “p” as appropriate, and then press Enter.
-
Type the other start and end times for your friends, Joy and Leslie.
-
In cell D2, subtract the end time from the start time by entering the formula =C2-B2, and then press Enter.
-
In the Format Cells box, click Custom in the Category list.
-
In the Type list, click h:mm (for hours and minutes), and then click OK.
Now we see that Richard worked 3 hours and 45 minutes.
-
To get the results for Joy and Leslie, copy the formula by selecting cell D2 and dragging to cell D4.
The formatting in cell D2 is copied along with the formula.
To subtract time that’s more than 24 hours:
It is necessary to create a formula to subtract the difference between two times that total more than 24 hours.
Follow the steps below:
-
Referring to the above example, select cell B1 and drag to cell B2 so that you can apply the format to both cells at the same time.
-
In the Format Cells box, click Custom in the Category list.
-
In the Type box, at the top of the list of formats, type m/d/yyyy h:mm AM/PM.
Notice the empty space at the end of yyyy and at the end of mm.
The new format will be available when you need it in the Type list.
-
In cell B1, type the start date, including month/day/year and time using either “a” or “p” for AM and PM.
-
In cell B2, do the same for the end date.
-
In cell B3, type the formula =(B2-B1)*24.
The result is 31.5 hours.
Note: You can add and subtract more than 24 hours in Excel for the web but you cannot apply a custom number format.
Add time
Suppose you want to know how many hours and minutes it will take to complete two tasks. You estimate that the first task will take 6 hours and 45 minutes and the second task will take 9 hours and 30 minutes.
-
In cell B2 type 6:45, and in cell B3 type 9:30.
-
Type =B2+B3 in cell B4, and then press Enter.
It will take 16 hours and 15 minutes to complete the two tasks.
Tip: You can also add up times using AutoSum. Click in cell B4. Then click Home > AutoSum. The formula will look like this: =SUM(B2:B3). Press Enter to get the result, 16 hours and 15 minutes.
Subtract time
Say you and your friends know your start and end times at a volunteer project, and want to know how much time you spent. In other words, you want the elapsed time or the difference between two times.
-
In cell B2 type the start time, enter a space, and then type “a” for AM or “p” for PM, and press Enter. In cell C2, type the end time, including “a” or “p” as appropriate, and press Enter. Type the other start and end times for your friends Joy and Leslie.
-
In cell D2, subtract the end time from the start time by typing the formula: =C2-B2, and then pressing Enter. Now we see that Richard worked 3 hours and 45 minutes.
-
To get the results for Joy and Leslie, copy the formula by clicking in cell D2 and dragging to cell D4. The formatting in cell D2 is copied along with the formula.
I have in cel A1 with the following contents:
7:30:43
which is a time.
But now i want to use a formula to add one hour. What is the best way or how can i do this?
asked Sep 21, 2011 at 21:05
1
=A1+TIME(1,0,0)
Although, maybe this should be posted on Super User.
apaderno
28.2k16 gold badges76 silver badges89 bronze badges
answered Sep 21, 2011 at 21:08
leonigmigleonigmig
2,7363 gold badges25 silver badges21 bronze badges
2
In cell A1, enter the time.
In cell B2, enter =A1+1/24
Anonymous
11.7k6 gold badges35 silver badges57 bronze badges
answered Mar 18, 2014 at 15:16
jennyjenny
1411 silver badge2 bronze badges
This may help you as well. This is a conditional statement that will fill the cell with a default date if it is empty but will subtract one hour if it is a valid date/time and put it into the cell.
=IF((Sheet1!C4)="",DATE(1999,1,1),Sheet1!C4-TIME(1,0,0))
You can also substitute TIME
with DATE
to add or subtract a date or time.
Pᴇʜ
56k9 gold badges49 silver badges73 bronze badges
answered Sep 21, 2011 at 23:49
Return to Excel Formulas List
Download Example Workbook
Download the example workbook
This tutorial will demonstrate how to add hours to a time in Excel and Google Sheets.
Add Hour
In Excel, time is stored as a fractional value where each 1/24th represents one hour of the day.
To add an hour add 1/24 to a time
=B3+(1/24)
or 12/24 to add 12 hours:
=B3+(12/24)
Add Hour to Now
To add an hour to the current time, add 1/24 to the NOW Function:
=NOW()+(1/24)
Add Hours Google Sheets
All of the above examples work exactly the same in Google Sheets as in Excel.
Home / Excel Formulas / Add Hours into Time (Excel Formula)
To add an hour value into a time value in Excel, you can use a simple and short formula where you need to specify the original time from a cell and the hour(s) value that you want to add after dividing it by the 24 (which are totals hours that we have in a day).
In the following example, we have a time value in cell A1 (12:01 AM). And here you need to add 3 hours
Following steps that you can use to add an hour in a time:
- First, refer to the cell where you have the time value (that’s A1 our example).
- After that, enter the sum operator and type the starting parentheses.
- Next, enter the hour value you want to add to the original time.
- Now, enter a division operator and type 24 which is the total number of hours that you have in a day.
- In the end, type closing parentheses and hit enter to get the result value.
=A1+(3/24)
The formula is quite simple. You just need to specify the original time hour value (divide it by 24).
Use Time Function to Add Time
You can also use the time function to add an hour to a time value. You can see this in the following formula.
You need to specify the original time, use the time function, and only specify the hour argument with the hours that you want to add.
=A1+TIME(3,0,0)
Содержание
- Add time
- Want more?
- Add or subtract time
- Add time
- Subtract time
- Add time
- Subtract time
- How to add hours, minutes and seconds in Excel
- Excel allows you to perform all kinds of operations
- How to do it
- all keys
- Format cells for minutes and seconds
- How to calculate time in Excel — time difference, adding / subtracting times
- How to calculate time difference in Excel (elapsed time)
- Formula 1. Subtract one time from the other
- Formula 2. Calculating time difference with the TEXT function
- Formula 3. Count hours, minutes or seconds between two times
- Formula 4. Calculate difference in one time unit ignoring others
- Formula 5. Calculate elapsed time from a start time to now
- Formula 5. Display time difference as «XX days, XX hours, XX minutes and XX seconds»
- How to calculate and display negative times in Excel
- Method 1. Change Excel Date System to 1904 date system
- Method 2. Calculate negative time in Excel with formulas
- Adding and subtracting time in Excel
- How to add or subtract hours to time in Excel
- How to add / subtract minutes to time in Excel
- How to add / subtract seconds to a given time
- How to sum time in Excel
- How to sum over 24 hours in Excel
- Date & Time Formula Wizard — quick way to calculate times in Excel
Add time
The best way to add time is to use the AutoSum button on the HOME tab. You can also add a unit of time, such as 1½ hours, to a time of day, such as 10:00 a.m., by using the TIME function.
Suppose that you want to know how many hours and minutes it will take to complete two tasks. You estimate that the first task will take 6 hours and 45 minutes and the second task will take 9 hours and 30 minutes.
In cell B2, type 6:45, and in cell B3, type 9:30.
Type =B2+B3 in cell B4, and then press Enter.
It will take 16 hours and 15 minutes to complete the two tasks.
You can also add up times by using AutoSum to sum numbers.
Click in cell B4. Then on the HOME tab, click AutoSum. The formula will look like this: =SUM(B2:B3). Press Enter to get the result, 16 hours and 15 minutes.
Want more?
You can add time in Excel just like you add other types of numbers.
For example, you might do this if you want to know how long it took to complete a project’s tasks.
The best way to do this is to use the AutoSum button on the HOME tab.
I click it once to see what it is going to add.
This is what I want, so I click it again, and get the total time for the tasks.
You could use AutoSum again to add these column’s tasks, or a formula to add these two cells.
To start a formula, you always use an = sign, click cell D2, type the + sign, click cell D3, and press Enter.
12 hours and 45 minutes plus 15 hours and 30 minutes, isn’t 4 hours and 15 minutes.
I know the formula is correct, so it must be how cell D4 is configured to display time.
In this example, the total is greater than 24 hours.
Excel can display time in many different ways, such as hours and minutes, or hours, minutes, and seconds; a.m., p.m., or a 24-hour clock; or a number that is greater than 24 hours, as is needed in this example.
To format the cell, right-click it, and click Format Cells.
Under Category, click Custom. In the Type field, type left square bracket, h, right square bracket, colon, and then, mm.
The square brackets tell Excel to exceed 24 hours.
The h is for hours and the mm is for minutes.
See the course summary at the end of this course for more information about formatting time. And now, we just click OK, and the total time is displayed correctly.
You can use the square brackets even if the time won’t exceed 24 hours.
If you are not sure if a total will exceed 24 hours, it is best to use them.
Источник
Add or subtract time
Let’s say that you need to add two different time values together to get a total. Or, you need to subtract one time value from another to get the total time spent working on a project.
As you’ll see in the sections below, Excel makes it easy to add or subtract time.
Add time
Suppose that you want to know how many hours and minutes it will take to complete two tasks. You estimate that the first task will take 6 hours and 45 minutes and the second task will take 9 hours and 30 minutes.
Here is one way to set this up in the a worksheet.
Enter 6:45 in cell B2, and enter 9 :30 in cell B3.
In cell B4, enter =B2+B3 and then press Enter.
The result is 16:15—16 hours and 15 minutes—for the completion the two tasks.
Tip: You can also add up times by using the AutoSum function to sum numbers. Select cell B4, and then on the Home tab, choose AutoSum. The formula will look like this: =SUM(B2:B3). Press Enter to get the same result, 16 hours and 15 minutes.
Well, that was easy enough, but there’s an extra step if your hours add up to more than 24. You need to apply a special format to the formula result.
To add up more than 24 hours:
In cell B2 type 12:45, and in cell B3 type 15:30.
Type =B2+B3 in cell B4, and then press Enter.
The result is 4:15, which is not what you might expect. This is because the time for Task 2 is in 24-hour time. 15:30 is the same as 3:30.
To display the time as more than 24 hours, select cell B4.
On the Home tab, in the Cells group, choose Format, and then choose Format Cells.
In the Format Cells box, choose Custom in the Category list.
In the Type box, at the top of the list of formats, type [h]:mm;@ and then choose OK.
Take note of the colon after [h] and a semicolon after mm.
The result is 28 hours and 15 minutes. The format will be in the Type list the next time you need it.
Subtract time
Here’s another example: Let’s say that you and your friends know both your start and end times at a volunteer project, and want to know how much time you spent in total.
Follow these steps to get the elapsed time—which is the difference between two times.
In cell B2, enter the start time and include “ a” for AM or “ p” for PM. Then press Enter.
In cell C2, enter the end time, including “ a” or “ p” as appropriate, and then press Enter.
Type the other start and end times for your friends, Joy and Leslie.
In cell D2, subtract the end time from the start time by entering the formula =C2-B2, and then press Enter.
In the Format Cells box, click Custom in the Category list.
In the Type list, click h:mm (for hours and minutes), and then click OK.
Now we see that Richard worked 3 hours and 45 minutes.
To get the results for Joy and Leslie, copy the formula by selecting cell D2 and dragging to cell D4.
The formatting in cell D2 is copied along with the formula.
To subtract time that’s more than 24 hours:
It is necessary to create a formula to subtract the difference between two times that total more than 24 hours.
Follow the steps below:
Referring to the above example, select cell B1 and drag to cell B2 so that you can apply the format to both cells at the same time.
In the Format Cells box, click Custom in the Category list.
In the Type box, at the top of the list of formats, type m/d/yyyy h:mm AM/PM.
Notice the empty space at the end of yyyy and at the end of mm.
The new format will be available when you need it in the Type list.
In cell B1, type the start date, including month/day/year and time using either “ a” or “ p” for AM and PM.
In cell B2, do the same for the end date.
In cell B3, type the formula =(B2-B1)*24.
The result is 31.5 hours.
Note: You can add and subtract more than 24 hours in Excel for the web but you cannot apply a custom number format.
Add time
Suppose you want to know how many hours and minutes it will take to complete two tasks. You estimate that the first task will take 6 hours and 45 minutes and the second task will take 9 hours and 30 minutes.
In cell B2 type 6:45, and in cell B3 type 9:30.
Type =B2+B3 in cell B4, and then press Enter.
It will take 16 hours and 15 minutes to complete the two tasks.
Tip: You can also add up times using AutoSum. Click in cell B4. Then click Home > AutoSum. The formula will look like this: =SUM(B2:B3). Press Enter to get the result, 16 hours and 15 minutes.
Subtract time
Say you and your friends know your start and end times at a volunteer project, and want to know how much time you spent. In other words, you want the elapsed time or the difference between two times.
In cell B2 type the start time, enter a space, and then type “ a” for AM or “ p” for PM, and press Enter. In cell C2, type the end time, including “ a” or “ p” as appropriate, and press Enter. Type the other start and end times for your friends Joy and Leslie.
In cell D2, subtract the end time from the start time by typing the formula: =C2-B2, and then pressing Enter. Now we see that Richard worked 3 hours and 45 minutes.
To get the results for Joy and Leslie, copy the formula by clicking in cell D2 and dragging to cell D4. The formatting in cell D2 is copied along with the formula.
Источник
How to add hours, minutes and seconds in Excel
One of the most used office programs in companies is Microsoft Office Excel, thanks to the variety of functions that this spreadsheet has. Currently, Excel is an almost mandatory program to have a computer in the work office, and Excel is generally used to organize information and make calculations in a simple way. There are some important tricks, too, among them being able to add time units.
Excel allows you to perform all kinds of operations
And it is that Excel is a very effective tool to obtain meaningful information from large amounts of data. It also works great for simple calculations and for keeping track of almost any type of information.
The key to unlocking all this potential is the cell grid. Cells can contain numbers, text, or formulas. Data is written to cells and grouped into rows and columns. This allows you to add data, sort and filter it , put it in tables and create very visual graphs.
Please enable JavaScript
Precisely within the data to be managed in Excel is the time type data . These can represent a problem for many users due to the task to be carried out on them, especially everything related to the sums of hours, minutes and seconds, since when we must carry out this type of operation.
How to do it
However, Microsoft’s table calculator not only succeeds because it allows you to create tables very easily and use its many calculation functions. Probably the most used Excel function is Sum, the function allows you to quickly add different values.
But what if we don’t just want to add numbers, but rather hours and minutes? In those, the truth is that adding hours and minutes in Excel is not a simple task, since it is necessary to apply some tricks to be able to do it in the right way. If you are one of those people who first adds up the minutes and then converts them into hours, then this advice is for you.
With this, to calculate the hours, the first thing we must do is give the correct format to the cells in which we are going to enter the values. The best way to put the hours is in hh:mm format.
all keys
After the cell format, we will have a large number of options available. Now it’s just choosing the format that corresponds to what you want to do, click the OK button and it’s applied to the selected cells.
Cell formats are one of the points that you have to master yes or yes in Excel due to their versatility and because they are key to making the sheets well done and to be able to operate normally with special values such as dates. There we will have created a format of hours:minutes:seconds. If we wanted only hours and minutes, the format would have been hh:mm.
Later, to express minutes and seconds in a cell, the information must be entered using the format hh:mm:ss . This format allows us to display the exact number of hours, minutes, and seconds. If you want to enter the value of 320 minutes and 55 seconds, you must do it as follows: 0:320:55 It is important to place the leading zero so that Excel interprets the minute and second data correctly.
Format cells for minutes and seconds
Another way around this problem is to start with a time that includes a date value . This allows you to subtract very large numbers from minutes without danger of getting a negative result. If you don’t want the date to be displayed in the result, simply apply a time-only numeric format.
To have the information with the format we need, we must right-click on the cell and select the Format Cells option and, within the custom section, place the following value in the text box for Type: [mm]:ss. When accepting the changes, Excel will show the value of the cell with the format we need. In the same way you can format a list that contains information of minutes and seconds and then do the sum as if it were any other type of data.
The advantage of using this method is that when adding seconds, Excel will automatically add one minute for every 60 seconds added. We would have to do this conversion manually if we have the minutes and seconds in separate columns, although, in most cases, Excel recognizes that you have entered a time and modifies the format automatically.
Источник
How to calculate time in Excel — time difference, adding / subtracting times
by Svetlana Cheusheva, updated on January 19, 2023
This tutorial focuses on various ways to calculate times in Excel. You will find a few useful formulas to add and subtract times, calculate time difference, or elapsed time, and more.
In the last week’s article, we had a close look at the specificities of Excel time format and capabilities of basic time functions. Today, we are going to dive deeper into Excel time calculations and you will learn a few more formulas to efficiently manipulate times in your worksheets.
How to calculate time difference in Excel (elapsed time)
To begin with, let’s see how you can quickly calculate elapsed time in Excel, i.e. find the difference between a beginning time and an ending time. And as is often the case, there is more than one formula to perform time calculations. Which one to choose depends on your dataset and exactly what result you are trying to achieve. So, let’s run through all methods, one at a time.
Add and subtract time in Excel with a special tool
No muss, no fuss, only ready-made formulas for you
Easily find difference between two dates in Excel
Get the result as a ready-made formula in years, months, weeks, or days
Calculate age in Excel on the fly
And get a custom-tailored formula
Formula 1. Subtract one time from the other
As you probably know, times in Excel are usual decimal numbers formatted to look like times. And because they are numbers, you can add and subtract times just as any other numerical values.
The simplest and most obvious Excel formula to calculate time difference is this:
Depending on you data structure, the actual time difference formula may take various shapes, for example:
Formula | Explanation |
=A2-B2 | Calculates the difference between the time values in cells A2 and B2. |
=TIMEVALUE(«8:30 PM») — TIMEVALUE(«6:40 AM») | Calculates the difference between the specified times. |
=TIME(HOUR(A2), MINUTE(A2), SECOND(A2)) — TIME(HOUR(B2), MINUTE(B2), SECOND(B2)) | Calculates the time difference between values in cells A2 and B2 ignoring the date difference, when the cells contain both the date and time values. |
Remembering that in the internal Excel system, times are represented by fractional parts of decimal numbers, you are likely to get the results similar to this:
The decimals in column D are perfectly true but not very meaningful. To make them more informative, you can apply custom time formatting with one of the following codes:
Time code | Explanation |
h | Elapsed hours, display as 4. |
h:mm | Elapsed hours and minutes, display as 4:10. |
h:mm:ss | Elapsed hours, minutes and seconds, display as 4:10:20. |
To apply the custom time format, click Ctrl + 1 to open the Format Cells dialog, select Custom from the Category list and type the time codes in the Type box. Please see Creating a custom time format in Excel for the detailed steps.
And now, let’s see how our time difference formula and time codes work in real worksheets. With Start times residing in column A and End times in column B, you can copy the following formula in columns C though E:
The elapsed time is displayed differently depending on the time format applied to the column:
Note. If the elapsed time is displayed as hash marks (#####), then either a cell with the formula is not wide enough to fit the time or the result of your time calculations is a negative value.
Formula 2. Calculating time difference with the TEXT function
Another simple technique to calculate the duration between two times in Excel is using the TEXT function:
- Calculate hours between two times: =TEXT(B2-A2, «h»)
- Return hours and minutes between 2 times: =TEXT(B2-A2, «h:mm»)
- Return hours, minutes and seconds between 2 times: =TEXT(B2-A2, «h:mm:ss»)
- The value returned by the TEXT function is always text. Please notice the left alignment of text values in columns C:E in the screenshot above. In certain scenarios, this might be a significant limitation because you won’t be able to use the returned «text times» in other calculations.
- If the result is a negative number, the TEXT formula returns the #VALUE! error.
Formula 3. Count hours, minutes or seconds between two times
To get the time difference in a single time unit (hours ,minutes or seconds), you can perform the following calculations.
Calculate hours between two times:
To present the difference between two times as a decimal number, use this formula:
Supposing that your start time is in A2 and end time in B2, you can use a simple equation B2-A2 to calculate the difference between two times, and then multiply it by 24, which is the number of hours in one day:
To get the number of complete hours, use the INT function to round the result down to the nearest integer:
Total minutes between two times:
To calculate the minutes between two times, multiply the time difference by 1440, which is the number of minutes in one day (24 hours * 60 minutes = 1440).
As demonstrated in the following screenshot, the formula can return both positive and negative values, the latter occur when the end time is less than the start time, like in row 5:
Total seconds between times:
To get the total seconds between two times, you multiply the time difference by 86400, which is the number of seconds in one day (24 hours * 60 minutes * 60 seconds = 86400).
In our example, the formula is as follows:
Note. For the results to display correctly, the General format should be applied to the cells with your time difference formula.
Formula 4. Calculate difference in one time unit ignoring others
To find the difference between 2 times in a certain time unit, ignoring the others, use one of the following functions.
- Difference in hours, ignoring minutes and seconds:
=HOUR(B2-A2)
Difference in minutes, ignoring hours and seconds:
=MINUTE(B2-A2)
Difference in seconds, ignoring hours and minutes:
When using Excel’s HOUR, MINUTE and SECOND functions, please remember that the result cannot exceed 24 for hours and 60 for minutes and seconds.
Note. If the end time is less than the start time (i.e. the result of the formula is a negative number), the #NUM! error is returned.
Formula 5. Calculate elapsed time from a start time to now
In order to calculate how much time has elapsed since the start time to now, you simply use the NOW function to return today’s date and the current time, and then subtract the start date and time from it.
Supposing that the beginning date and time is in call A2, the formula below returns the following results, provided you’ve applied an appropriate time format to column B, h:mm in this example:
In case the elapsed time exceeds 24 hours, use one of these time formats, for example d «days» h:mm:ss like in the following screenshot:
If your starting points contain only time values without dates, you need to use the TIME function to calculate the elapsed time correctly. For example, the following formula returns the time elapsed since the time value in cell A2 up to now:
=TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) — A2
Note. The elapsed time is not updated in real-time, it refreshes only when the workbook is reopened or recalculated. To force the formula to update, press either Shift + F9 to recalculate the active spreadsheet or hit F9 to recalculate all open workbooks.
Formula 5. Display time difference as «XX days, XX hours, XX minutes and XX seconds»
This is probably the most user-friendly formula to calculate time difference in Excel. You use the HOUR, MINUTE and SECOND functions to return corresponding time units and the INT function to compute the difference in days. And then, you concatenate all these functions in a single formula along with the text labels:
=INT(B2-A2) & » days, » & HOUR(B2-A2) & » hours, » & MINUTE(B2-A2) & » minutes and » & SECOND(B2-A2) & » seconds»
To instruct your Excel time difference formula to hide zero values, embed four IF functions into it:
=IF(INT(B2-A2)>0, INT(B2-A2) & » days, «,»») & IF(HOUR(B2-A2)>0, HOUR(B2-A2) & » hours, «,»») & IF(MINUTE(B2-A2)>0, MINUTE(B2-A2) & » minutes and «,»») & IF(SECOND(B2-A2)>0, SECOND(B2-A2) & » seconds»,»»)
The syntax may seem excessively complicated, but it works 🙂
Alternatively, you can calculate time difference by simply subtracting the start time from the end time (e.g. =B2-A2 ), and then apply the following time format to the cell:
d «days,» h «hours,» m «minutes and» s «seconds»
An advantage of this approach is that your result would be a normal time value that you could use in other time calculations, while the result of the complex formula discussed above is a text value. A drawback is that the custom time format cannot distinguish between zero and non-zero values and ignore the latter. To display the result in other formats, please see How to show time over 24 hours, 60 minutes, 60 seconds.
How to calculate and display negative times in Excel
When calculating the time difference in Excel, you may sometimes get the result as ###### error because the difference is a negative time. But is there a way to show negative times properly in Excel? Of course, there is a way, and even more than one 🙂
Method 1. Change Excel Date System to 1904 date system
The fastest and easiest way to display negative time normally (with a minus sign) is switching to the 1904 date system. To do this, click File > Options > Advanced, scroll down to the When calculating this workbook section and put a tick in the Use 1904 date system box.
Click OK to save the new settings, and from now on negative times will be displayed correctly, like negative numbers:
Method 2. Calculate negative time in Excel with formulas
Is changing Excel’s default Date System is not an option, then you can force negative times to display properly using one of the following formulas:
=IF(A2-B2>0, A2-B2, «-» & TEXT(ABS(A2-B2),»h:mm»))
=IF(A2-B2>0, A2-B2, TEXT(ABS(A2-B2),»-h:mm»))
Both formulas check if the time difference (A2-B2) is greater than 0, and if it is they return that difference. If the time difference is less than zero, the first formula calculates the absolute difference and concatenates the minus sign. The second formula yields exactly the same result by using a negative time format «-h::mm«.
Note. Please keep in mind that unlike the first method that treats negative times as negative numeric values, the result of the TEXT function is always a text string that cannot be used in calculations or other formulas.
Adding and subtracting time in Excel
Basically, there are 2 ways to add and subtract time in Excel:
- Using the TIME function
- Using arithmetic calculations based on the number of hours (24), minutes (1440) and seconds (86400) in one day
The TIME(hour, minute, second) function makes Excel time calculations really easy, however it does not allow adding or subtracting more than 23 hours, or 59 minutes, or 59 seconds. If you are working with bigger time intervals, then use one of the arithmetic calculations demonstrated below.
How to add or subtract hours to time in Excel
To add hours to a given time in Excel, you can use one the following formulas.
TIME function to add under 24 hours
For example, if your start time is in cell A2, and you want to add 2 hours to it, the formula is as follows:
Note. If you try adding more than 23 hours with the TIME function, the specified hours will be divided by 24 and the remainder will be added to the start time value. For example, if you try to add 25 hours to «6/2/2015 10:00 AM» (cell A4) using the formula =A4 + TIME(25, 0, 0) , the result will be «06/02/2015 11:00», i.e. A4 + 1 hour.
Formula to add any number of hours (under or over 24 hours)
The following formula has no limitations to the number of hours you want to add:
For example, to add 28 hours to the start time in cell A2, enter the following formula:
To subtract hours from a given time, you use analogous formulas, and just replace «+» with the minus sign:
For example, to subtract 3 hours from the time in cell A2, either of the following formulas will do:
To subtract more than 23 hours, use the first one.
How to add / subtract minutes to time in Excel
To add minutes to a given time, employ the same techniques that we’ve just used for adding hours.
To add or subtract under 60 minutes
Use the TIME function and supply the minutes you want to add or subtract in the second argument:
And here are a couple of real-life formulas to calculate minutes in Excel:
To add 20 minutes to the time in A2: =A2 + TIME(0,20,0)
To subtract 30 minutes from the time in A2: =A2 — TIME(0,30,0)
To add or subtract over 60 minutes
In your calculation, divide the number of minutes by 1440, which is the number of minutes in a day, and add the quotient to the start time:
To subtract minutes from time, simply replace plus with the minus sign. For example:
To add 200 minutes: =A2 + (200/1440)
To subtract 300 minutes: =A2 -(300/1440)
How to add / subtract seconds to a given time
Second calculations in Excel are done in a similar fashion.
To add under 60 seconds to a given time, you can use the TIME function:
To add more than 59 seconds, use the following formula:
To subtract seconds, utilize the same formulas with the minus sign (-) instead of plus (+).
In your Excel worksheets, the formulas may look similar to these:
To add 30 seconds to A2: =A2 + TIME(0,0,31)
To add 1200 seconds to A2: =A2 + (1200/86400)
To subtract 40 seconds from A2: =A2 — TIME(0,0,40)
To subtract 900 seconds from A2: =A2 — (900/86400)
How to sum time in Excel
The Excel sum time formula is the usual SUM function, and applying the proper time format to the result is what does the trick.
Supposing you have a few project times in column B and you want to add them up. You write a simple SUM formula like the one below and get the result in the default format such as hh:mm:ss.
In some cases the default time format works just fine, but sometimes you may want more, for example to display the total time as minutes and seconds, or seconds only. The good news is that no other calculations are required, all you have to do is apply custom time format to the cell with the SUM formula.
Right click the cell and select Format Cells in the context menu, or press Ctrl + 1 to open the Format Cells dialog box. Select Custom from the Category list and type one of the following time formats in the Type box:
- To display total time as minutes and seconds: [m]:ss
- To display total time as seconds: [ss]
The result will look as follows:
How to sum over 24 hours in Excel
In order to add up more than 24 hours, you use the same SUM formula as discussed above, and apply one of the following time formats to the cell:
Format | Displays as | Explanation |
[h]:mm | 30:10 | Hours and minutes |
[h]:mm:ss | 30:10:20 | Hours, minutes and seconds |
[h] «hours», mm «minutes», ss «seconds» | 30 hours, 10 minutes, 20 seconds | |
d h:mm:ss | 1 06:10:20 | Days, hours, minutes and seconds |
d «day» h:mm:ss | 1 day 06:10:20 | |
d «day,» h «hours,» m «minutes and» s «seconds» | 1 day, 6 hours, 10 minutes and 20 seconds |
To see how these custom time formats may look like in your Excel worksheet, please have a look at the screenshot below, where the same SUM formula is entered in cells A9 to A13:
Note. The above custom time formats work for positive values only. If the result of your time calculations is a negative number, e.g. when you are subtracting a bigger time from a smaller time, the result will be displayed as #####. To display negative times differently, please see custom format for negative time values.
Also, please keep in mind that the time format applied to a cell changes only the display presentation without changing the cell’s value. For example, in the screenshot above, cell A13 looks like text, but in fact it’s a usual time value, which is stored as a decimal in the internal Excel system. Meaning, you are free to refer to that cell in other formulas and calculations.
Date & Time Formula Wizard — quick way to calculate times in Excel
Now that you know a bunch of different formulas to add and subtract times in Excel, let me show you the tool that can do it all. Okay, almost all 🙂
Here comes Ablebit’s Date & Time Formula Wizard for Excel:
In the Date & Time Wizard dialog window, you switch to the Add or Subtract tab, depending on which operation you want to perform, and do the following:
- Click the Show time fields link in the left part of the window.
- Supply values or cell references for the formula arguments. As you fill in the argument boxes, the wizard builds the formula in the selected cell.
- When finished, click the Insert Formula
That’s it! For example, this is how you can add the specified number of hours, minutes and seconds to the time in A4:
If you need to copy the formula to other cells, fix all references except the cell containing the original time (A4) with the $ sign like shown in the screenshot below (by default, the wizard always uses relative references). Then double-click the fill handle to copy the formula down the column and you are good to go!
Besides time calculations, the wizard can also add and subtract dates, get the difference between two dates, and calculate age from the birthdate.
If you are curious to try this tool in your own worksheets, you are welcome to download the evaluation version of our Ultimate Suite below.
This is how you calculate time in Excel worksheets. To learn other ways to manipulate dates and times in Excel, I encourage you to check out the resources at the end of this article. I thank you for reading and hope to see you on our blog next week!
Источник