WPS Spreadsheets: Fix Overtime Calculations with Multiple Breaks
Question details
The user needs to calculate total worked hours and overtime across several clock-in and clock-out periods, including shifts that pass midnight.
- Product
- WPS Spreadsheets
- Device & OS
- not provided
- Scenario
- A workday contains multiple in-and-out periods in pairs such as C:D, E:F, and G:H. Regular working hours are stored in I1, and the user needs the remaining overtime in hours.
- Observed behavior
- Time calculations can return #VALUE! when blank text values such as "" are included in arithmetic, especially when multiple breaks or overnight shifts are involved.
Check that each clock-in and clock-out cell contains a real time value rather than text, and confirm that I1 contains the regular-hours target as a numeric value in hours. Identify every clock-in/clock-out pair that should contribute to the total.
Calculate each work interval numerically and subtract regular hours
Use this formula when several break periods may be blank or when a shift can cross midnight.
Calculate every in-and-out pair separately so incomplete pairs contribute zero instead of blank text. MOD(end-start,1) keeps overnight intervals positive, and multiplying the total by 24 converts the spreadsheet time fraction into hours.
Select the overtime result cell and enter =MAX(0,SUM(IF(OR(C1="",D1=""),0,MOD(D1-C1,1)),IF(OR(E1="",F1=""),0,MOD(F1-E1,1)),IF(OR(G1="",H1=""),0,MOD(H1-G1,1)))*24-I1). Replace the cell references if your clock-in, clock-out, or regular-hours cells are different.
Press Enter in WPS Spreadsheets and verify that a complete interval adds hours while a blank pair adds zero. The MAX(0,...) portion prevents negative overtime from appearing when total worked time is below regular hours.
Select the result cell, open the Home tab, choose the Number Format control, and apply Number for decimal hours or a duration format when you want to display elapsed time.
Test a pair such as 10:00 PM in C1 and 2:00 AM in D1. The MOD(D1-C1,1) portion should calculate four hours instead of a negative value.
Use a duration result when overtime should display as hours and minutes
Choose this approach when the result should appear as a time duration such as 02:30 instead of decimal hours.
Calculate Multi-Period Overtime in WPS Spreadsheets
WPS Spreadsheets can calculate multiple work intervals, ignore incomplete break pairs, handle shifts that cross midnight, and display overtime as decimal hours or a duration without introducing blank text into the formula.
- 1. Open the workbook: Launch WPS Office, select Spreadsheets, and open the worksheet containing the clock-in and clock-out columns.
- 2. Review the time cells: Select the input cells and use the Home tab's Number Format menu to confirm they are formatted as Time and contain actual time values.
- 3. Insert the overtime formula: Select the overtime result cell and enter the multi-interval formula with IF, OR, MOD, SUM, and MAX to ignore blank pairs and account for midnight crossings.
- 4. Format and verify the result: Use the Home tab's Number Format control to choose Number or [h]:mm, then test a complete shift, a blank break pair, and an overnight interval.

Frequently Asked Questions
Why does a multiple-break overtime formula return #VALUE! in WPS Spreadsheets?
The formula is likely combining numeric times with text values such as "". Calculate each clock-in/clock-out pair with IF(OR(start="",end=""),0,MOD(end-start,1)) so incomplete pairs return numeric zero.
How do I calculate an overnight shift from 10 PM to 6 AM?
Use MOD(clock_out-clock_in,1), such as MOD(D1-C1,1). MOD converts the negative result caused by the midnight crossing into the correct elapsed duration.
How can I ignore a blank break period?
Wrap each pair in IF and OR: IF(OR(E1="",F1=""),0,MOD(F1-E1,1)). This treats a missing clock-in or clock-out as zero rather than adding blank text to the calculation.
How do I subtract regular hours from total worked hours?
If regular hours are stored as decimal hours in I1, multiply the summed spreadsheet time by 24 and subtract I1. For example, use MAX(0,SUM(intervals)*24-I1) to prevent negative overtime.
Should the overtime result use Number or Time formatting?
Use Number when you want decimal hours such as 2.5. Use a duration format such as [h]:mm when you want hours and minutes, especially for totals that may exceed 24 hours.




