Calculate Elapsed Time and Breaks in Excel with MOD
Question details
Calculate elapsed hours across midnight and subtract a break entered in a separate cell.
- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A worksheet records a start time, an end time, and a break duration in decimal hours.
- Observed behavior
- The desired result is the elapsed time in decimal hours, minus the break, even when the shift ends after midnight.
Check that F3 contains the start time, E3 contains the end time, and G3 contains the break in decimal hours. Format E3 and F3 as Time, and enter times with a space before AM or PM, such as 10:15 PM.
Use MOD to Calculate Hours Across Midnight and Subtract a Break
Use this formula for a shift shorter than 24 hours when the break is recorded as decimal hours.
MOD adjusts the time difference when the end time is after midnight. Multiplying by 24 converts Excel's fraction of a day to hours, so the break can be subtracted in decimal hours.
In Excel, enter the start time in F3 and the end time in E3, for example, 10:15 PM and 4:20 AM. Select both cells and choose a Time format from the Home tab's Number format menu.
In G3, enter the break as decimal hours. For example, enter 1.25 for a 1-hour, 15-minute break.
Select an empty result cell, enter =MOD(E3-F3,1)*24-G3, and press Enter.
Select the result cell and choose Number from the Home tab's Number format menu. Adjust the displayed decimal places if needed.
Calculate Overnight Work Hours in WPS Spreadsheet
Use the same MOD formula in WPS Spreadsheet to calculate hours across midnight and subtract a break in decimal hours.
- 1. Open the worksheet: Open WPS Spreadsheet and select Open to choose your workbook, or create a new spreadsheet.
- 2. Enter the times and break: Enter the start time in F3, the end time in E3, and the break in decimal hours in G3. For example, enter 1.25 for a 1-hour, 15-minute break.
- 3. Apply the formula: Select an empty cell, enter =MOD(E3-F3,1)*24-G3, and press Enter.
- 4. Format the result: Select the result cell and use the Home tab's Number format menu to display it as a number with the desired decimal places.

Frequently Asked Questions
Why does the formula use MOD?
MOD(E3-F3,1) returns the time difference within a day, including when the end time in E3 is after midnight and appears earlier than the start time in F3.
How do I enter a 30-minute break?
Enter 0.5 in G3. The formula expects the break in decimal hours, not minutes.
What if my break is entered as a time value?
If G3 contains a duration such as 1:15 rather than 1.25, use =MOD(E3-F3,1)*24-G3*24 to convert the break to decimal hours before subtracting it.
Why isn't Excel calculating my entered times?
Check that E3 and F3 contain recognized time values rather than text. Reenter them with a space before AM or PM, such as 10:15 PM, and select Time from the Home tab's Number format menu.
Can this formula calculate a shift longer than 24 hours?
Not reliably with time-only entries. Enter both dates and times in F3 and E3, then use =(E3-F3)*24-G3 to calculate the full duration in decimal hours.




