# How to Calculate Hours from Date and Time in Excel

Get FREE Advanced Excel Exercises with Solutions!

Sometimes we need to calculate the hour  between 2 times from different or the same date. It’s quite simple to do in Excel. We can find the hour difference in several ways. In this article, we will discuss 6 such easy and simple methods to calculate hours from date and time in Excel.

## 6 Easy Methods to Calculate Hours from Date and Time in Excel

We can calculate hours from date and time in Excel following different methods. Here we will show you 6 simple and easy methods to calculate hours from date and time in Excel. In our dataset, we can see the starting time (B5:B7) and the end time (C5:C7) of a small project. Now, we will calculate the hours.

### Method 1: Subtract One Time from Another to Calculate Hours in Excel

In this method, we will directly subtract one time from another to calculate the hour difference. We are discussing the steps below for this method.

• In the dataset we select the date and time first to change the format.
• First, select the cell range B5:C7. • Go to Number Format of the Home tab in the ribbon and select More Number Formats. • From the Format cell box, we select the Custom format and choose dd-mm-yy h:mm as the format type.
• Then press OK. • Now, we select the cells for Difference in Hours to change its format also. • From the Format Cells box, we select the Custom Category and choose [h] as the format type.
• After that, press OK. • Next, we write the following formula in cell D5 and hit Enter.
`=C5-B5`
• Use the Fill Handle to copy the formula in the cells below. In the formula C5-B5 denotes the difference of time from the two cells in hour.
• We have calculated the hour difference between two different times successfully.

### Method 2: Get Hours from Date and Time with Excel TEXT Function

We can also use The TEXT Function of Excel to get the hour difference between two dates and times. We need to fix the format of the cells (B5:C7) by following the procedure from  Method 1.

• First, in cell D5 we write the following formula and hit Enter.
`=TEXT(C5-B5,"h")`
• Next, use the Fill Handle to copy the formula in the below cells. Here, the TEXT function displays the difference C5-B5 in “h” (Hour) format.

### Method 3: Count Hours, Minutes, Seconds Using Simple Formula

We can also calculate the difference between two dates and times in hours, minutes and seconds by using a very simple formula. Following procedures from  Method 1 we need to fix the formats of the cell range B5:C7 first. Then we follow the following steps.

• In the beginning, we write the following formula in cell D5 and press Enter.
`=(C5-B5)*24`
• Now, use the Fill handle to copy the formula in the following cells. In this formula we multiplied the difference C5-B5 by 24 to get the hours difference.
• Then we write the formula given below in cell E5 and hit Enter.
`=(C5-B5)*1440`
• We copy the formula in the below cells using the Fill Handle. Here, we multiplied the difference C5-B5 by 1440 to get the minutes difference.
• After that, in cell F5 we write the formula given below and press Enter.
`=(C5-B5)*86400`
• Now, we copy the formula in the cells below using the Fill Handle. We calculated the seconds by multiplying the difference C5-B5 with 86400.
• Yahoo! We have successfully calculated the difference of time in hours, minutes and seconds.

### Method 4: Calculate Elapsed Hours in Excel from Start Time to Present

We can calculate the elapsed time by subtracting the starting time from present time. Excel has the NOW function to determine the present date and time, we will use that in this method. We fix the formats for the cells (B5:C7) by following procedures from Method 1. We are showing the steps for this method below.

• Firstly, write the following formula in cell C5 and hit Enter.
`=NOW()-B5`
• After that, use AutoFill to see the result below. The NOW function gives the present time from where we subtracted the time from cell B5.

### Method 5: Display Time Difference as Days, Hours, Minutes, Seconds Format

In this method we will calculate the difference as days, months, minutes and seconds. Following procedures from Method 1, we fix the cell (B5:C7) format first. Now we follow the steps given below.

• Write the following formula in cell D5 and hit Enter.
`=INT(C5-B5) & " days, " & HOUR(C5-B5) & " hours, " & MINUTE(C5-B5) & " minutes and " & SECOND(C5-B5) & " seconds"` In the formula the INT function calculates the integer number of difference C5-B5 which gives the days. The HOUR function, the MINUTE function & the SECOND function do similar tasks in the formula and return in hour, minute & second format respectively.
• Further, we use the Fill Handle to copy the formula in the following cells. • Finally, we have calculated the difference of time in days, hours, minutes and seconds.

### Method 6: Calculate and Display Negative Hours from Date and Time in Excel

So far we calculated the time difference as positive, we may want to subtract the time from any past time which will give a negative difference. We fix the cell (B5:C7) format following procedures from Method 1. We can calculate the negative hours following the steps below.

• First, write the following formula in cell D5 and press Enter.
`=IF(C5-B5>0, C5-B5, "-" & TEXT(ABS(C5-B5),"h"))`
• Then, use the Fill Handle to copy the formula in the cells below. Here, we used the IF function of Excel. C5-B5>0 is the criteria, C5-B5 is the result if criteria match. If the criteria does not match then a negative sign is given before the result. The TEXT function gives the output as hour. The ABS function gets the absolute value of C5-B5.
• Hurrah! We have successfully calculated the negative hour difference.

## Conclusion

Hour difference is very useful in time of different date and time calculations. It’s quite easy in Excel to find the hour difference. In this article, we have shown 6 easy methods to calculate hours from date and time in Excel. If you face any problem following the steps, please let us know by commenting. Please visit our ExcelDemy site for similar articles regarding Excel.

## Related Articles Mehedi Hasan Shimul

Hi! I am Mehedi Hasan Shimul. As I am an Engineer solving different problems with the help of Excel amuses me. I write Excel related different problem solving articles here. Hope it will help you.

We will be happy to hear your thoughts Advanced Excel Exercises with Solutions PDF  