Calculation Issues

Calculate Hours Worked from Clock-In and Clock-Out Times in Excel

Ayan MasoodAyan Masood Nov 18, 2026 870 views

Question details

Calculate elapsed working time from clock-in and clock-out values in Excel.

Calculate Hours Worked from Clock-In and Clock-Out Times 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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the times

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.

2
Calculate elapsed time

Select cell C1, enter =B1-A1, and press Enter.

3
Format the result

Select C1, open Format Cells, choose Number > Custom, and enter [h]:mm as the format. The example displays 9:00.

4
Use decimal hours instead

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.

Subtract clock-in from clock-out for a same-day shift
Breaks are not deducted: The formula calculates the full elapsed interval. Subtract any unpaid break time separately if needed.
Calculate work hours in WPS

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. 1. Open a spreadsheet: Open WPS Spreadsheet and create a blank workbook or open an existing Excel file.
  2. 2. Enter clock times: Enter the clock-in time in A1 and the clock-out time in B1.
  3. 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. 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.
Calculate same-day and overnight work intervals with spreadsheet formulasOpen and edit Microsoft Excel XLS and XLSX filesUse a familiar spreadsheet interface with custom number formatsUse WPS Office as a free, lightweight office suite
microsoft office alternative - wps office

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.