Calculate Overnight Shift Hours in Excel
Question details
Calculate elapsed work hours for a shift that crosses midnight.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A shift starts at 10:35 PM and ends at 7:15 AM the next day.
- Observed behavior
- The user needs the total duration and may also need the hours assigned to each calendar day.
Enter the start and end times as recognizable time values in Excel, such as 10:35 PM and 7:15 AM. The formulas below assume the shift is shorter than 24 hours and do not subtract unpaid breaks.
Calculate the total shift duration with MOD
Use this formula when a shift may end after midnight and lasts less than 24 hours.
In Excel, enter 10:35 PM in cell A2 and 7:15 AM in cell B2.
Select cell C2, enter =MOD(B2-A2,1), and press Enter.
Select C2, open Format Cells, choose Custom, and enter [h]:mm in the Type box. The example displays 8:40.

Split shift hours between calendar days
Use separate formulas to show the time before and after midnight.
Calculate Overnight Shift Hours in WPS Spreadsheets
Use the MOD formula in WPS Spreadsheets to calculate a shift that crosses midnight, then format the result as a duration.
- 1. Open a spreadsheet: Open WPS Spreadsheets and create a workbook or open an existing Excel file.
- 2. Enter the shift times: Enter the start time in A2 and the end time in B2, such as 10:35 PM and 7:15 AM.
- 3. Add the formula: Select C2, enter =MOD(B2-A2,1), and press Enter.
- 4. Format the result: Select C2, open Format Cells, choose Custom, and enter [h]:mm to display the duration as hours and minutes.

Frequently Asked Questions
How many hours is a shift from 10:35 PM to 7:15 AM?
The elapsed time is 8 hours and 40 minutes, before subtracting any unpaid breaks. In Excel, enter the times in A2 and B2 and use =MOD(B2-A2,1).
How can I display the result as decimal hours?
Use =MOD(B2-A2,1)*24 and format the result as a number. For the example shift, the result is approximately 8.67 hours.
How do I subtract an unpaid break?
Enter the break duration as a time in D2, such as 0:30, and use =MOD(B2-A2,1)-D2. Format the result as [h]:mm.
Can the MOD formula calculate a shift lasting more than 24 hours?
No. MOD discards whole days. Enter full start and end dates and times, use =B2-A2, and format the result as [h]:mm.




