Calculate Regular and Overtime Hours by Day and Time in Excel
Question details
Allocate worked hours to regular, overtime, night, and public holiday columns based on the day and time worked.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- A timesheet contains shifts that need to be classified by weekday, time band, and holiday status.
- Observed behavior
- Each worked interval should contribute hours to the appropriate category without counting the same hours twice.
Enter actual dates and times for each shift, and prepare a list of public holiday dates. Confirm your organization's working hours and pay rules; the example below uses specific sample rules that may need adjustment.
Split shifts at midnight and calculate each time category
Use copied formulas to allocate hours into separate, nonoverlapping categories in Excel.
This example treats Monday through Friday from 9:00 AM to 5:00 PM as regular time, 10:00 PM to 6:00 AM as night time, and remaining nonholiday hours as overtime. All hours on a listed holiday go into the holiday column, even if they are also night hours.
These are example allocation rules, not a calculation of overtime based on weekly thresholds or pay rates. Change the time bands and category rules to match your policy.
In columns A and B, enter each interval's start and end as full date-and-time values. If a shift crosses midnight, split it into two rows: end the first at midnight on the next date and start the second at that same midnight. Each row must start and end within one calendar day, except that its end may be midnight at the start of the next day.
Enter public holiday dates without times in H2:H50. Add headers in C1:F1 for Holiday Hours, Night Hours, Regular Hours, and Overtime Hours.
In C2, enter =IF(COUNTIF($H$2:$H$50,INT(A2))>0,(B2-A2)*24,0). In D2, enter =IF(COUNTIF($H$2:$H$50,INT(A2))>0,0,(MAX(MIN(B2,INT(A2)+TIME(6,0,0))-MAX(A2,INT(A2)),0)+MAX(MIN(B2,INT(A2)+1)-MAX(A2,INT(A2)+TIME(22,0,0)),0))*24).
In E2, enter =IF(OR(COUNTIF($H$2:$H$50,INT(A2))>0,WEEKDAY(A2,2)>5),0,MAX(MIN(B2,INT(A2)+TIME(17,0,0))-MAX(A2,INT(A2)+TIME(9,0,0)),0)*24). In F2, enter =(B2-A2)*24-C2-D2-E2.
Select C2:F2 and drag the fill handle down for the remaining intervals. Format columns C:F as numbers; their sum on each row should equal =(B2-A2)*24. Check a weekday, a weekend, a holiday, and a shift split at midnight.

Allocate Shift Hours in WPS Spreadsheet
Use WPS Spreadsheet to enter shift intervals and apply the same overlap formulas for regular, overtime, night, and holiday hours.
- 1. Open your timesheet: Open WPS Spreadsheet and use File > Open to select your Excel timesheet, or create a new spreadsheet.
- 2. Enter intervals and holidays: Put full start and end date-time values in columns A and B, splitting any shift at midnight. Enter holiday dates in H2:H50.
- 3. Add the allocation formulas: Enter the holiday, night, regular, and overtime formulas from the solution above in cells C2:F2, then drag the fill handle down.
- 4. Check and save: Format C:F as numbers, check that each row's categories add up to its worked hours, and use File > Save As to save the timesheet in Excel format.

Frequently Asked Questions
How do I handle a shift that crosses midnight?
Split it into two rows at midnight, using full date-and-time values in columns A and B. This lets each row use the correct weekday and holiday date.
Do the formulas count holiday night hours twice?
No. The example puts all hours on a listed holiday in the holiday column and returns zero night and regular hours for that date.
How can I change the regular working hours?
In the E2 formula, replace TIME(9,0,0) and TIME(17,0,0) with your regular start and end times. Review the night and overtime rules too if the new bands overlap.
Can I use these formulas for weekly overtime thresholds?
Not by themselves. The example assigns remaining hours by day and time; a weekly threshold requires additional calculations that total hours by workweek and apply your policy.




