Calculation Issues

WPS Spreadsheets: Fix Overtime Calculations with Multiple Breaks

Bushra ParveenBushra Parveen Nov 12, 2026 869 views

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.
Before you start

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.

Solution 1Recommended

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.

1
Enter the interval formula

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.

2
Confirm the formula

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.

3
Format the result correctly

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.

4
Check an overnight interval

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.

Keep time calculations numeric: Do not concatenate or add blank text such as "" to time values before performing arithmetic. Handle missing pairs with IF and OR instead.
WPS Spreadsheet solution

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. 1. Open the workbook: Launch WPS Office, select Spreadsheets, and open the worksheet containing the clock-in and clock-out columns.
  2. 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. 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. 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.
Handles multiple clock-in and clock-out periods in one formulaUses MOD to calculate overnight shifts correctlySupports decimal-hour and [h]:mm duration displaysOpens and saves Microsoft Excel XLSX and XLS files with familiar spreadsheet formulas
microsoft office alternative - wps office

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.