Calculate Total Hours Worked on a Date in Excel
Question details
Calculate the total time worked on a selected date, including the portions of shifts that cross midnight.

- 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.
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.
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.
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.
Select E2 and drag its fill handle down through the remaining shift rows. The $D$2 reference keeps the target date fixed.
In an empty cell, enter =SUM(E2:E100), adjusting the range to include all relevant shift rows.
Select the overlap cells and the total, press Ctrl+1, and choose Number > Custom. Enter [h]:mm as the format and select OK.

Total the selected date's hours for one employee
Use SUMIF after calculating each shift's daily overlap when the worksheet contains multiple employees.
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. Open your worksheet: Open WPS Spreadsheet and use File > Open to select your shift worksheet.
- 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. 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. Format the durations: Select the results and total, open Format Cells, and choose a custom number format of [h]:mm.

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.




