Calculate Overnight Shifts and Lunch Breaks in Excel
Question details
Calculate an overnight shift with a lunch break, round the result to the nearest quarter hour, and separate regular hours from overtime.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- An employee clocks in, clocks out and back in for lunch, and finishes a shift that may cross midnight.
- Observed behavior
- The timecard can return negative values when the shift ends after midnight.
Enter all four punches as Excel time values: start, lunch out, lunch in, and shift end. The formulas below assume each worked interval is less than 24 hours and that all four punches are present.
Calculate and round overnight hours with lunch punches
Use MOD to handle midnight in either worked interval, then cap regular hours at 12.25 and calculate the remainder as overtime.
In row 4, enter the shift start in C4, lunch out in D4, lunch in in E4, and shift end in F4.
In G4, enter =ROUND((MOD(D4-C4,1)+MOD(F4-E4,1))*96,0)/4. This adds the two worked intervals and rounds the total to the nearest quarter hour.
In H4, enter =MIN(G4,12.25) to limit regular time to 12.25 hours.
In I4, enter =MAX(G4-H4,0) to show rounded hours above the regular-hours limit.
Select G4:I4 and choose Home > Number to display the results as numbers. Drag the fill handle down to apply the formulas to other completed timecard rows.

Build an overnight timecard in WPS Spreadsheet
Use the same time and rounding formulas in WPS Spreadsheet to calculate overnight shifts, subtract lunch, and split regular hours from overtime.
- 1. Open the timecard: Open WPS Spreadsheet and use Open to select your Excel timecard, or create a blank workbook.
- 2. Enter the punches: In row 4, enter the start, lunch out, lunch in, and end times in C4, D4, E4, and F4 respectively.
- 3. Calculate total hours: In G4, enter =ROUND((MOD(D4-C4,1)+MOD(F4-E4,1))*96,0)/4.
- 4. Split regular and overtime hours: Enter =MIN(G4,12.25) in H4 and =MAX(G4-H4,0) in I4. Format G4:I4 as numbers using the Home tab.
- 5. Apply and save: Drag the fill handle from G4:I4 down to other completed rows, then use File > Save As to save the workbook in XLSX format.

Frequently Asked Questions
Why does an overnight shift show negative hours in Excel?
If you subtract a late start time from an after-midnight end time without a date, the end time is numerically smaller. Use MOD(end-start,1) for an interval shorter than 24 hours.
How do I calculate hours when there are no lunch punches?
With the start in C4 and end in F4, enter =ROUND(MOD(F4-C4,1)*96,0)/4. This assumes the shift is shorter than 24 hours.
Can I change the regular-hours limit?
Yes. Replace 12.25 in =MIN(G4,12.25) with your applicable limit. If overtime is calculated with =MAX(G4-H4,0), it will use the revised regular-hours result.
Why does 7.5 appear instead of 7 hours and 30 minutes?
The formulas return decimal hours. A result of 7.5 means 7 hours and 30 minutes; select the result cells and use Home > Number to display decimal places.




