Calculation Issues

How to Calculate Work Shifts Longer Than 24 Hours in Excel

Anum MushtaqAnum Mushtaq Nov 4, 2026 869 views

Question details

The user needs to calculate the total duration of work shifts that span multiple days or exceed 24 hours without encountering formatting errors or negative values.

How to Calculate Work Shifts Longer Than 24 Hours in Excel
Product
Excel
Device & OS
not provided
Scenario
Tracking employee timesheets and calculating total worked hours for overnight or multi-day shifts where standard subtraction results in errors or incorrect durations.
Observed behavior
Using standard time subtraction for shifts over 24 hours either produces negative values, hashtag errors (####), or a duration that incorrectly resets to zero after passing the 24-hour mark.
Before you start

Ensure that your start and end cells contain both the full date and time, as omitting the date makes it impossible for the spreadsheet to calculate shifts lasting longer than 24 hours.

Solution 1Recommended

Subtract Complete Date-Times and Apply Elapsed Hours Formatting

This is the standard and most reliable method for calculating multi-day shifts by recording complete date-time values and using a custom format to display hours beyond a 24-hour cycle.

By default, standard time formatting operates on a 24-hour clock. This means a 26-hour shift will display as 2:00. To fix this, you must apply a custom elapsed time format.

1
Enter the full start date and time

In cell A2, type your starting value including the date, for example: 10/25/2023 08:00 AM.

2
Enter the full end date and time

In cell B2, type the ending value including the date, for example: 10/26/2023 10:00 AM.

3
Apply the subtraction formula

In cell C2, type the formula =B2-A2 to calculate the difference between the end and start times.

4
Format the result cell

Select cell C2, right-click it, and choose 'Format Cells'. Navigate to the 'Custom' category.

5
Apply the [h]:mm format

In the Type field, enter [h]:mm and click OK. The brackets instruct the software to display total elapsed hours, showing 26:00 instead of resetting.

Subtract Complete Date-Times and Apply Elapsed Hours Formatting
Formatting Tip: Verify that your typed date format matches your system's regional settings (e.g., MM/DD/YYYY vs DD/MM/YYYY) to prevent value errors.
Seamless Timesheet Management

Easily Calculate Complex Timesheets in WPS Spreadsheet

WPS Spreadsheet is a powerful, free tool that perfectly handles complex time calculations, overnight multi-day shifts, and custom elapsed time formatting seamlessly.

  1. 1. Open your document: Launch WPS Spreadsheet and open your timesheet file.
  2. 2. Enter the date-time data: Ensure that your shift data includes both the exact date and the time.
  3. 3. Input the formula: Type =(End Cell) - (Start Cell) in your Total Hours column.
  4. 4. Apply elapsed time format: Right-click the result, select Format Cells, choose Custom, and type [h]:mm to accurately display hours over 24.
100% compatible with Microsoft Excel formulas, date formats, and custom time formats.Easily calculate shifts over 24 hours with intuitive [h]:mm formatting.Free to use and runs smoothly on Windows, macOS, and Linux devices.
microsoft office alternative - wps office

Frequently Asked Questions

Why does my time calculation show negative numbers or hashtag (####) errors?

This usually occurs when the end time is earlier than the start time in a 24-hour cycle and no date is provided, or if your date format doesn't match your computer's regional settings. Including both the date and time in the cell resolves this.

Can I calculate overnight shifts without typing the date?

Yes, but only if the shift is under 24 hours. You can use the formula =MOD(End-Start, 1) or =IF(End<Start, End+1, End)-Start. For any shift exceeding 24 hours, including the complete dates is mandatory.

How do I stop my total hours from resetting to zero after 24 hours?

You need to apply a custom cell format. By formatting the result cell as [h]:mm instead of h:mm, the square brackets force the spreadsheet to display the total accumulated hours rather than following a standard 24-hour clock cycle.

How can I display time properly as a decimal for payroll?

To represent hours worked as a decimal number (e.g., 8.5 hours instead of 8:30), subtract the start time from the end time and multiply by 24 using the formula =(End-Start)*24. Then format the resulting cell as a standard Number with two decimal places.