Calculation Issues

Calculate Overnight Shift Hours in Excel

Anum MushtaqAnum Mushtaq Dec 2, 2026 868 views

Question details

Calculate elapsed work hours for a shift that crosses midnight.

Calculate Overnight Shift Hours in Excel
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.
Before you start

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.

Solution 1Recommended

Calculate the total shift duration with MOD

Use this formula when a shift may end after midnight and lasts less than 24 hours.

1
Enter the shift times

In Excel, enter 10:35 PM in cell A2 and 7:15 AM in cell B2.

2
Calculate elapsed time

Select cell C2, enter =MOD(B2-A2,1), and press Enter.

3
Format the duration

Select C2, open Format Cells, choose Custom, and enter [h]:mm in the Type box. The example displays 8:40.

Calculate the total shift duration with MOD
Shifts of 24 hours or more: MOD returns the time difference within a single day. For longer shifts, enter both dates and times and subtract the start from the end without MOD.
Calculate shift hours in WPS

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. 1. Open a spreadsheet: Open WPS Spreadsheets and create a workbook or open an existing Excel file.
  2. 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. 3. Add the formula: Select C2, enter =MOD(B2-A2,1), and press Enter.
  4. 4. Format the result: Select C2, open Format Cells, choose Custom, and enter [h]:mm to display the duration as hours and minutes.
Calculate overnight shifts with a simple MOD formulaOpen and edit Microsoft Excel XLSX and XLS filesUse a familiar spreadsheet interfaceGet started with WPS Office for free
microsoft office alternative - wps office

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.