Calculate Hours Worked from Clock-In and Clock-Out Times in Excel
Question details
Calculate elapsed working time from clock-in and clock-out values in Excel.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A user has clock-in and clock-out times in a worksheet and wants the hours worked as elapsed time or decimal hours.
- Observed behavior
- Subtracting valid Excel time values returns a fraction of a day, which can be formatted as elapsed time or converted to decimal hours.
Enter clock-in and clock-out values as recognizable Excel times, such as 7:00 AM and 4:00 PM. Check whether shifts can cross midnight and whether the values include dates.
Subtract clock-in from clock-out for a same-day shift
Use a simple subtraction formula when both times are on the same day and clock-out is later than clock-in.
Excel stores time as a fraction of a day. The difference can be displayed as elapsed hours and minutes or multiplied by 24 to produce decimal hours.
Enter the clock-in time in cell A1 and the clock-out time in cell B1, for example 7:00 AM and 4:00 PM.
Select cell C1, enter =B1-A1, and press Enter.
Select C1, open Format Cells, choose Number > Custom, and enter [h]:mm as the format. The example displays 9:00.
To display decimal hours, enter =(B1-A1)*24 in the result cell and use Home > Number to apply a Number format. The example returns 9.

Calculate an overnight shift from time-only values
Use MOD when clock-out is after midnight and the shift lasts less than 24 hours.
Calculate Clock-In and Clock-Out Hours in WPS Spreadsheet
Use WPS Spreadsheet to subtract time entries, format elapsed hours, and convert the result to decimal hours.
- 1. Open a spreadsheet: Open WPS Spreadsheet and create a blank workbook or open an existing Excel file.
- 2. Enter clock times: Enter the clock-in time in A1 and the clock-out time in B1.
- 3. Enter the formula: In C1, enter =B1-A1 for a same-day shift. For an overnight shift lasting less than 24 hours, enter =MOD(B1-A1,1).
- 4. Format the hours: Select C1, open Format Cells > Number > Custom, and enter [h]:mm. For decimal hours instead, multiply the formula by 24 and apply a Number format.

Frequently Asked Questions
Why does Excel show a decimal instead of hours and minutes?
Excel stores time as a fraction of a day. Select the result cell, open Format Cells > Number > Custom, and enter [h]:mm to display elapsed hours and minutes.
How do I calculate hours when a shift ends after midnight?
If A1 contains clock-in and B1 contains clock-out, enter =MOD(B1-A1,1) and format the result as [h]:mm. Use this for time-only shifts lasting less than 24 hours.
How do I get decimal hours for payroll?
For a same-day shift, enter =(B1-A1)*24 and apply a Number format. For an overnight shift under 24 hours, use =MOD(B1-A1,1)*24 instead.
How can I subtract an unpaid break?
Enter the break duration as a time value in another cell, such as D1, then use =B1-A1-D1 for a same-day shift. Format the result as [h]:mm.
Can I calculate a shift longer than 24 hours?
Yes. Enter both the date and time for clock-in and clock-out, subtract the complete values with =B1-A1, and format the result as [h]:mm.




