Calculation Issues

Count Overnight Employee Shift Overlaps in WPS Spreadsheets

Huma Ashraf ChHuma Ashraf Ch Nov 12, 2026 869 views

Question details

Count employees whose shifts overlap four-hour schedule periods, including periods and shifts that continue past midnight.

Count Overnight Employee Shift Overlaps in WPS Spreadsheets
Product
WPS Spreadsheets
Device & OS
not provided
Scenario
A staff schedule needs employee totals for time blocks such as 11:00 PM to 3:00 AM, with some shift end times occurring on the following day.
Observed behavior
Time-only values can make overnight shifts appear to end before they start, causing incorrect employee counts.
Before you start

Use separate columns for each employee's shift start and shift end. Enter full date-time values for overnight shifts so the end date is the following day, rather than storing both values as times on the same date.

Solution 1Recommended

Count employees who work at any time during an overnight period

Use this method when an employee should be counted if any part of their shift overlaps the selected period.

A shift overlaps a period when the shift starts on or before the period end and ends on or after the period start. This works reliably when every start and end value includes a date as well as a time.

1
Set up date-time columns

In WPS Spreadsheets, place shift start date-times in column B and shift end date-times in column C. Enter the period start in F2 and the period end in G2, then format these cells with Home > Number Format > Date and Time.

2
Set the overnight period end to the next day

For a period from 11:00 PM to 3:00 AM, enter the correct next-day date in G2. For example, if F2 is 1/10/2026 11:00 PM, enter 1/11/2026 3:00 AM in G2.

3
Enter the overlap count formula

Select the result cell and enter =SUMPRODUCT((B2:B100<=$G$2)*(C2:C100>=$F$2)). This counts each shift that overlaps the period at any point.

4
Fill or copy for other periods

Create separate period start and end cells for each four-hour block, then copy the formula and update the referenced period cells as needed.

Count employees who work at any time during an overnight period
Overnight shifts are counted correctly: For example, a shift from 12:30 PM on January 10 to 1:00 AM on January 11 overlaps the January 10 11:00 PM to January 11 3:00 AM period.
Work with schedules in WPS Spreadsheets

Calculate Overnight Staff Coverage with WPS Spreadsheets

WPS Spreadsheets lets you store shift boundaries as date-time values and use SUMPRODUCT formulas to count employees who overlap or fully cover overnight schedule periods.

  1. 1. Open the schedule workbook: Open the staff schedule in WPS Spreadsheets and identify the shift date, start time, and end time columns.
  2. 2. Create date-time boundaries: Combine each shift date with its start and end time, adding one day to an end value when the shift crosses midnight.
  3. 3. Add period start and end cells: Enter each four-hour period as a start and end date-time, using the next date for an overnight period end.
  4. 4. Apply an overlap formula: Use =SUMPRODUCT((StartRange<=PeriodEnd)*(EndRange>=PeriodStart)) to count employees working at any time in the period.
Build accurate overnight shift calculations with date-time values.Use SUMPRODUCT to count partial overlap or complete period coverage.Open, edit, and save Microsoft Excel .xlsx and .xls staff schedules.Use a familiar spreadsheet interface for formulas, formatting, and schedule updates.
QA img-9

Frequently Asked Questions

Why does an overnight shift return the wrong count when I use only times?

A time such as 1:00 AM is numerically earlier than 12:30 PM on the same date. Add the shift date to both values and assign the end time to the following date when it is earlier than the start time.

What formula counts a shift that overlaps a period at all?

Use =SUMPRODUCT((StartRange<=PeriodEnd)*(EndRange>=PeriodStart)). For example, with starts in B2:B100, ends in C2:C100, period start in F2, and period end in G2, use =SUMPRODUCT((B2:B100<=$G$2)*(C2:C100>=$F$2)).

How do I count only employees who work the complete four-hour block?

Use =SUMPRODUCT((StartRange<=PeriodStart)*(EndRange>=PeriodEnd)). With the same example cells, enter =SUMPRODUCT((B2:B100<=$F$2)*(C2:C100>=$G$2)).

How should I enter an 11:00 PM to 3:00 AM period?

Enter the start with its date and 11:00 PM, then enter the end as 3:00 AM on the following date. For example, use 1/10/2026 11:00 PM and 1/11/2026 3:00 AM.

Can I keep start and end times in separate cells from the shift date?

Yes. Create helper date-time values with =ShiftDate+StartTime and =ShiftDate+EndTime+(EndTime<StartTime), then use those helper columns in your counting formulas.