How to Calculate Elapsed Time and Subtract 8 Hours in Excel
Question details
The user needs an Excel formula to calculate the elapsed hours between a start time and a finish time, and conditionally subtract eight hours if a specific status cell indicates overtime (OT).

- Product
- Excel
- Device & OS
- not provided
- Scenario
- Tracking employee work hours and calculating billable overtime based on logged start and finish times.
- Observed behavior
- The user's original formula produced a syntax error because it included extra equals signs inside the IF function expression.
Ensure your start and finish time cells are properly formatted as Time, and your result cell is formatted as a Number or General to correctly display the calculated decimal hours.
Use the IF and MOD Functions to Calculate Time
This method uses the IF function to check for the 'OT' status and the MOD function to accurately calculate the time difference even if the shift crosses midnight.
When calculating elapsed time, multiplying the difference by 24 converts Excel's fractional day value into standard decimal hours. The MOD function prevents negative results for overnight shifts.
Click the cell where you want the calculated total hours to appear.
Type the following formula: =IF(G4="OT",MOD(E4-D4,1)*24-8,MOD(E4-D4,1)*24). In this example, G4 is the status cell, E4 is the finish time, and D4 is the start time.
Press Enter to calculate the result. Ensure there is only one equals sign at the very beginning of the formula.

Use a Shorter Boolean Logic Formula
A more concise version of the formula uses boolean multiplication instead of the IF function to conditionally subtract the eight hours.
Calculate Overtime and Elapsed Hours Easily in WPS Office
WPS Spreadsheet provides comprehensive support for complex time calculations, MOD functions, and conditional logic. It is an intuitive tool that helps you manage timesheets flawlessly.
- 1. Open your Timesheet: Launch WPS Spreadsheet and open your work hours tracking document.
- 2. Input the Formula: Click the target cell and type =MOD(E4-D4,1)*24-8*(G4="OT").
- 3. Format the Cell: Right-click the cell, select 'Format Cells', and choose 'Number' to display the hours correctly as a decimal.
- 4. Drag to Apply: Click and drag the fill handle at the bottom right corner of the cell to apply the calculation to the rest of your timesheet rows.

Frequently Asked Questions
Why do I need to multiply by 24 when calculating time differences?
In spreadsheet programs, time is stored as a fraction of a 24-hour day. Multiplying the elapsed time by 24 converts the fractional day value into standard decimal hours, making it easier to calculate wages.
Why is the MOD function used for time calculations?
The MOD function, specifically MOD(Finish-Start, 1), is used to handle situations where a work shift crosses midnight. It ensures the calculated time remains a positive and accurate value even if the finish time is numerically smaller than the start time.
How do I fix a #VALUE! error in my time formula?
A #VALUE! error usually occurs if the start or finish time cells contain text or hidden spaces instead of actual time values. Check your cells to ensure they are properly formatted as Time and delete any invisible characters.




