How to Calculate Time in Excel (17 Possible Ways)

For illustration, we will use the sample dataset below.

Dataset of how to calculate time in Excel


Method 1 – Calculate Time Difference in Excel Using Operator

⏩ In cell E4, type the following formula.

=D4-C4

Calculate Time Difference in Excel Using Operator

We selected D4 and C4 cells and then subtracted the C4 cell time from D4.

Press ENTER to get the time difference.

AutoFill the formula for the rest of the cells.

Calculate Time Difference in Excel Using Operator


1.1. Change Time Format in h, h:mm and h:mm:ss format

Whenever we use an operator to get the time difference, the output is in the existing format. You have to change the format if you want it in a different format.

Select the cell or cell range that you want to change the format.

➤ I selected the cell range E4:E11.

Open the Home tab >> from Number group >> select the Number Format icon.

Change Time Format in h, h:mm and h:mm:ss format

A dialog box will appear.

⏩ Select custom and type h.

Click OK.

The selected cell range time will be converted to hours.

Change Time Format in h, h:mm and h:mm:ss format

Select the cell or cell range that you want to change the format.

➤ I selected the cell range F4:F11.

Oopen the Home tab >> from Number group >> select the Number Format icon.

A dialog box will appear.

⏩ Select custom and type h:mm.

Click OK.

Change Time Format in h, h:mm and h:mm:ss format

The selected cell range time will be converted into only hours & minutes.

Use the same process to convert the time into an hour, minute & second format.

Change Time Format in h, h:mm and h:mm:ss format


Method 2 – Calculate Time Difference in Hours

⏩ In cell E4, type the following formula.

=(D4-C4)*24

Calculate Time Difference in Hours

Press ENTER to get the time difference in hours.

AutoFill the formula for the rest of the cells.

Calculate Time Difference in Hours

To get the hour without decimal values, use the INT function.

⏩ In cell F4, type the following formula.

=INT((D4-C4)*24)

The INT function will return only the integer values.

Press ENTER to get the time difference in integer hours.

Calculate Time Difference in Hours

AutoFill the formula for the rest of the cells.

Calculate Time Difference in Hours

To calculate the time difference in minutes, use this formula:

=(D4-C4)*24*60

To calculate the time difference in seconds, use this formula:

=(D4-C4)*24*60*60

Method 3 – Using Excel TEXT Function to Calculate Time Difference in Hours

⏩ In cell E4, type the following formula.

=TEXT(D4-C4,"hh")

Using Excel TEXT Function to Calculate Time Difference in Hours

Press ENTER to get the time difference in hours.

AutoFill the formula for the rest of the cells.

Using Excel TEXT Function to Calculate Time Difference in Hours

For more ways to calculate the time difference you can check the article How to Calculate Time Difference.


Method 4 – Calculating Elapsed Time Using Excel NOW Function

⏩ In cell D4, enter the following formula.

=NOW()-C4

Press ENTER to get the elapsed time from the selected date.

Calculating Elapsed Time Using Excel NOW Function

AutoFill the formula for the rest of the cells.


Method 5 – Calculating Elapsed Time Using TIME Function

In case your dataset contains only time values without dates, you will need to use the TIME function to calculate the elapsed time correctly.

Dataset for Calculating Elapsed Time Using TIME Function

⏩ In cell D4, type the following formula.

=TIME(HOUR(NOW()), MINUTE(NOW()), SECOND(NOW())) - C4

Formula for Calculating Elapsed Time Using TIME Function

Press ENTER to get the elapsed time.

Output for Calculating Elapsed Time Using TIME Function

AutoFill the formula for the rest of the cells.

Using Fill Handle tool for Calculating Elapsed Time Using TIME Function


Method 6 – Calculating Elapsed Time Using Excel TEXT & NOW Function

⏩ In cell D4, type the following formula.

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

Calculating Elapsed Time Using Excel TEXT & NOW Function

Press ENTER to get the time elapsed in days, hours, minutes, and seconds format.

AutoFill the formula for the rest of the cells.

Calculating Elapsed Time Using Excel TEXT & NOW Function


Method 7 – Calculate & Show Time Difference

⏩ In cell D4, type the following formula.

=INT(D4-C4) & " days, " & HOUR(D4-C4) & " hours, " & MINUTE(D4-C4) & " minutes and " & SECOND(D4-C4) & " seconds"

Formula to Calculate & Show Time Difference in Excel

Press ENTER to get the time displayed in days, hours, minutes, and seconds text.

Output of Calculating & Showing Time Difference

AutoFill the formula for the rest of the cells.

Using Fill Handle to Calculate & Show Time Difference


Method 8 – Dealing Negative Time

There is a possibility of getting ###### errors in Excel while dealing with negative times.

But there are ways to show negative times properly in Excel without getting this error.

8.1. Using IF Function to Calculate Negative Time

⏩ In cell E4, type the following formula.

=IF((D4-C4)<0,1-(D4-C4),(D4-C4))

Using IF Function to Calculate Negative Time

Here, in the IF function, I used (D4-C4)<0 as logical_test, 1-(D4-C4) as value_if_true, and (D4-C4) as value_if_false.

Now, if the logical_test value becomes TRUE then the IF function will return the time difference subtracted by 1 otherwise the positive time difference will remain as it is.

Press ENTER to get a positive time.

AutoFill the formula for the rest of the cells.

Using IF Function to Calculate Negative Time


8.2. Using IF, TEXT & ABS Function to Calculate Negative Time

⏩ In cell E4, type the following formula.

=IF(D4-C4>0, D4-C4, TEXT(ABS(D4-C4),"-h:mm"))

Using IF, TEXT & ABS Function to Calculate Negative Time

Press ENTER to get the negative time difference.

AutoFill the formula for the rest of the cells.


Method 9 – Adding Hours in Excel with TIME function

9.1. Add Time Under 24 Hours in Excel

⏩ In cell D4, type the following formula.

=C4 + TIME(8, 0, 0)

Add Time Under 24 Hours in Excel

Here, in the TIME function, I used 8 as an hour and used 0 as a minute & second as I wanted to add only hours. Then added it with the time of cell C4.

Press ENTER to get the added time.

AutoFill the formula for the rest of the cells.

Add Time Under 24 Hours in Excel


9.2. Add Time Under or Over 24 Hours in Excel

⏩ In cell D4, type the following formula and press enter.

=C4+ (48/24)

Add Time Under or Over 24 Hours in Excel

AutoFill the formula for the rest of the cells.


Method 10 – Adding Minutes in Excel

10.1. Add Time Under 60 Minutes in Excel

⏩ In cell E4, type the following formula.

=C4 + TIME(0, D4, 0)

Add Time Under 60 Minutes in Excel

Press ENTER, and you will get added time.

AutoFill the formula for the rest of the cells.

Add Time Under 60 Minutes in Excel


10.2. Add Time Under or Over 60 Minutes in Excel

⏩ In cell D4, type the following formula.

=C4+ (480/1440)

Add Time Under or Over 60 Minutes in Excel

AutoFill the formula for the rest of the cells.


Method 11 – Adding Seconds in Excel

11.1. Add Time Under 60 Seconds

⏩ In cell E4, type the following formula.

=C4 + TIME(0, 0, D4)

Add Time Under 60 Seconds

AutoFill the formula for the rest of the cells.


11.2. Add Time Under or Over 60 Seconds

⏩ In cell E4, type the following formula.

=C4+ (320/86400)

Add Time Under or Over 60 Seconds

AutoFill the formula for the rest of the cells.


Method 12 – Subtract Hours in Excel

12.1. Subtract Time Under 24 Hours

⏩ In cell E4, type the following formula and press ENTER.

=C4 - TIME(D4, 0, 0)

Subtract Time Under 24 Hours

AutoFill the formula for the rest of the cells.


12.2. Subtract Time Under or Over 24 Hours

⏩ In cell D4, type the following formula.

=C4 - (48/24)

Subtract Time Under or Over 24 Hours

AutoFill the formula for the rest of the cells.

Read More: How to Subtract Time in Excel


Method 13 – Subtract Minutes in Excel

13.1. Subtract Time Under 60 Minutes

⏩ In cell E4, type the following formula and press ENTER.

=C4 - TIME(0, D4, 0)

Subtract Time Under 60 Minutes

AutoFill the formula for the rest of the cells.


13.2. Subtract Time Under or Over 60 Minutes

⏩ In cell D4, type the following formula and press ENTER.

=C4- (480/1440)

Subtract Time Under or Over 60 Minutes in Excel

AutoFill the formula for the rest of the cells.


Method 14 – Subtract Seconds in Excel

14.1. Subtract Time Under 60 Seconds

⏩ In cell E4, type the following formula and press enter.

=C4 - TIME(0, 0, D4)

Subtract Time Under 60 Seconds

AutoFill the formula for the rest of the cells.


14.2. Subtract Time Under or Over 60 Seconds

⏩ In cell D4, type the following formula.

=C4 -(488/86400)

Subtract Time Under or Over 60 Seconds

AutoFill the formula for the rest of the cells.


Method 15 – Calculate Total Time Using Excel SUM Function

⏩ In cell F4, type the following formula.

=SUM(C4:C8)

Calculate Total Time Using Excel SUM Function

Press ENTER and you will get the total time.


15.1. Calculate Total Minutes Using SUM

Select the cell or cell range that you want to change the format.

➤ I selected cell F4.

Open the Home tab >> from Number group >> select the Number Format icon.

Calculate Total Minutes Using SUM

A dialog box will appear.

⏩ Select custom and type [mm] to get only minutes.

Click OK.

The selected cell time will be converted into minutes.

Calculate Total Minutes Using SUM


15.2. Calculate Total Seconds Using SUM

⏩ Select custom and type [ss] to only get seconds.

Click OK.

Calculate Total Seconds Using SUM

The selected cell time will be converted into seconds.


Method 16 – Using TEXT & SUM to Calculate Total Time

⏩ In cell F4, type the following formula.

=TEXT(SUM(C4:C8),"[h]:mm:ss")

Using TEXT & SUM to Calculate Total Time

Press ENTER to get the formatted total time.


16.1. Using TEXT & SUM to Calculate Total Day & Time

⏩ In cell F4, type the following formula.

=TEXT(SUM(C4:C8),"dd hh:mm:ss")

Using TEXT & SUM to Calculate Total Day & Time

Press ENTER to get the formatted total time with the number of days.


Method 17 – How to Calculate Hours Worked in Excel

17.1 Using Simple Formula to Calculate Total Hours Worked

Insert the formula below in cell E4 >> press Enter key >> use the Fill Handle tool >> change the number format to the Number option.

=MOD(D4-C4,1)*24

Calculating total hours worked in Excel

Here, we applied the MOD function to avoid returning negative numbers in case the end time is earlier then the start time.


17.2 Combining IF and SUM Functions to Calculate Overtime

In cell E4, insert the following formula >> press Enter key >> drag down the Fill Handle tool.

=IF((D4-C4)*24>$H$4,$H$4,(D4-C4)*24)

Using IF and SUM function to calculate normal time in Excel

In cell F4, enter the following formula >> press Enter key >> drag down the Fill Handle icon. Don’t forget to change the number formatting to the Number option.

=IF((D4-C4)*24>$H$4,(D4-C4)*24-$H$4,0)

Using IF and SUM function to calculate over time in Excel


17.3 Calculate Hours Worked in a Weekly Timesheet

Insert the following formula in cell E4 >> press Enter key >>  use the Fill Handle tool to copy the formula.

=(D4-C4)*24

Calculating total hours worked in weekly time sheet

To calculate the overtime value for each workday, enter the following formula in cell G4 >> press Enter key >> drag down the Fill Handle icon.

=IF(SUM($E$4:E4)>$I$4,SUM($E$4:E4)-$I$4,0)

Using SUM and IF function to calculate Over time in Excel weekly time sheet

To calculate the normal time using the MAX function. Enter the following formula in cell F4 >> press the Enter key >> drag down the Fill Handle tool.

=MAX(E4-G4,0)

Using MAX function to calculate normal time

To find the total normal time and total overtime, insert the formula below in cell F9 >> press Enter key >> drag the Fill Handle tool to the right.

Applying SUM function to calculate total normal time and overtime in Excel


[Fixed] Results Showing Hash(#) Symbols Instead of Time or Date in Excel

In various instances of calculating time or date values, we get multiple Hash (#) symbols instead of the actual result. This can occur due to the column not being wide enough. In the following image, we have such a scenario.

Hash symbols instead of time or date result

To fix this, adjust the column width and the actual outputs will be visible.

Adjusting column width


Download Practice Workbook


Calculate Time in Excel: Knowledge Hub


<< Go Back to Date-Time in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Shamima Sultana
Shamima Sultana

Shamima Sultana, BSc, Computer Science and Engineering, East West University, Bangladesh, has been working with the ExcelDemy project for 2 years. She has written over 75+ articles and reviewed 1000+ articles for ExcelDemy. She has also led several teams with Excel VBA and Content Development works. Currently, she is working as the Project Manager and oversees the day-to-day work, leads the services team, allocates resources to the right area, etc. Her work and learning interests vary from Microsoft... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo