Calculation Issues

Calculate Total Hours Worked on a Date in Excel

Nimra MalikNimra Malik Dec 2, 2026 868 views

Question details

Calculate the total time worked on a selected date, including the portions of shifts that cross midnight.

Calculate Total Hours Worked on a Date in Excel
Product
Microsoft Excel
Device & OS
not provided
Scenario
A worksheet contains shift start and end date-times, and the user needs to total the hours that fall within one calendar date.
Observed behavior
The desired total includes only the portion of each shift between midnight on the selected date and midnight on the following date.
Before you start

Enter each shift's full start date and time in column A and full end date and time in column B, including the next day's date for overnight shifts. Enter the target date without a time in D2.

Solution 1Recommended

Calculate each shift's overlap with the target date

Use an overlap formula to count only the part of each shift that falls on the selected date, then sum the results.

Excel stores dates and times as numbers, so the formula returns a duration in days. Formatting the result as [h]:mm displays it as total hours and minutes.

1
Enter the overlap formula

In E2, enter =MAX(0,MIN(B2,$D$2+1)-MAX(A2,$D$2)). This limits the shift to the target date's midnight-to-midnight interval.

2
Apply it to other shifts

Select E2 and drag its fill handle down through the remaining shift rows. The $D$2 reference keeps the target date fixed.

3
Sum the durations

In an empty cell, enter =SUM(E2:E100), adjusting the range to include all relevant shift rows.

4
Format the results

Select the overlap cells and the total, press Ctrl+1, and choose Number > Custom. Enter [h]:mm as the format and select OK.

Calculate each shift's overlap with the target date
Example overnight shift: For a shift from 18:00 to 05:00 the next day, the formula counts 6:00 on the start date and 5:00 on the following date.
Calculate shift hours in WPS Spreadsheet

Calculate Overnight Shift Hours in WPS Spreadsheet

Use the same overlap formula in WPS Spreadsheet to count the hours worked on a selected date and total them across shifts.

  1. 1. Open your worksheet: Open WPS Spreadsheet and use File > Open to select your shift worksheet.
  2. 2. Enter the dates and shifts: Put full start and end date-times in columns A and B, and enter the target date without a time in D2.
  3. 3. Calculate and total overlaps: Enter =MAX(0,MIN(B2,$D$2+1)-MAX(A2,$D$2)) in E2, fill it down, and enter =SUM(E2:E100) in an empty cell, adjusting the range as needed.
  4. 4. Format the durations: Select the results and total, open Format Cells, and choose a custom number format of [h]:mm.
Count only the portion of an overnight shift that falls on the selected date.Open and save Microsoft Excel XLSX files.Use familiar spreadsheet formulas and custom time formats.
microsoft office alternative - wps office

Frequently Asked Questions

How do I count an overnight shift on each date?

Enter the full start and end date-times, then use =MAX(0,MIN(B2,$D$2+1)-MAX(A2,$D$2)) with the date you want to count in D2. Change D2 to the next date to calculate that day's portion.

Why does my total wrap around after 24 hours?

The cell may use a clock-time format. Select it, press Ctrl+1, and choose Number > Custom with the format [h]:mm to display total hours beyond 24.

Can I total hours for just one employee?

Yes. If names are in C2:C100, calculated overlaps are in E2:E100, and the employee name is in F2, use =SUMIF(C2:C100,F2,E2:E100).

What if my shift cells contain times but no dates?

Add the actual date to both the start and end values in columns A and B. For an overnight shift, the end value must include the following day's date so the formula can identify the correct overlap.