# How to Calculate Difference Between Two Times in Hours in Excel

To calculate the difference between two times in hours in Excel, follow these steps:

- Enter the two times in separate cells. Make sure they are in a time format (e.g., "hh:mm" or "hh:mm:ss"). You can set the time format by selecting the cell, right-clicking, choosing "Format Cells," and selecting the desired format under the "Time" category.
- In a new cell, subtract the earlier time from the later time by typing a formula like this:
`=B1-A1`

(replace "A1" and "B1" with the cell references of your two times). - To convert the result to hours, multiply by 24 (because there are 24 hours in a day). Update the formula like this:
`=(B1-A1)*24`

. - Finally, format the result cell to display the number as a decimal. Right-click the cell, choose "Format Cells," and select "Number" under the "Number" category. Adjust the decimal places if necessary.

## Example

Here's an example to demonstrate calculating the difference between two times in hours:

- Enter the start time in cell A1 (e.g., 9:00 AM).
- Enter the end time in cell B1 (e.g., 5:00 PM).
- In cell C1, enter the formula
`=(B1-A1)*24`

. - Format cell C1 as a number with decimal places.

The result in cell C1 will show the difference between the two times in hours, which is 8 hours in this example.

Did you find this useful?