How to Calculate Hours Worked in Excel
Calculate hours worked in Excel from start and end times, handle overnight shifts, and roll daily hours into weekly totals.
Calculating hours worked in Excel is usually simple when shifts start and end on the same day. It gets easier to break when the sheet includes lunch breaks, overnight shifts, or weekly overtime checks.
Start with clean time fields before adding payroll logic.
The basic formula
If A2 contains the start time and B2 contains the end time, use:
=(B2-A2)*24Excel stores time as a fraction of a day. Multiplying by 24 converts the result into hours.
For example, if A2 is 9:00 AM and B2 is 5:30 PM, the result is 8.5.
Subtract unpaid breaks
If C2 contains an unpaid break in hours, subtract it from the total:
=((B2-A2)*24)-C2If breaks are recorded in minutes, convert them to hours:
=((B2-A2)*24)-(C2/60)That keeps the result as a decimal hour total, which is easier to sum across a week.
Handle overnight shifts
Overnight shifts need a small adjustment because the end time is technically on the next day. If B2 is earlier than A2, add one day before calculating hours:
=IF(B2<A2, (B2+1-A2)*24, (B2-A2)*24)This works for shifts like 10:00 PM to 6:00 AM. Without the adjustment, Excel may return a negative result or a confusing time value.
Roll daily hours into weekly hours
Once each day has a daily-hour value, sum the week:
=SUM(D2:J2)In an employee schedule template, keep weekly hours visible next to the schedule grid. Managers should not have to hunt for the total when reviewing overtime or balancing shifts.
Flag overtime
For a basic overtime flag at 40 hours, use:
=IF(K2>40, "OT", "")If the overtime threshold differs by employee type, state, policy, or role, put the threshold in its own column and reference that instead of hard-coding 40.
NOTE
Common mistakes
| Problem | Cause | Fix |
|---|---|---|
| Negative hours | Overnight shift crosses midnight | Use the overnight IF formula |
| Weird decimal | Cell formatted as time | Format the result as Number |
| Wrong break math | Break minutes treated as hours | Divide break minutes by 60 |
| Weekly total is wrong | Some daily cells contain text | Keep daily-hour cells numeric |
The Griddy way
Hour formulas are easy to write once, but easy to damage when the schedule changes or new shift types get added.
"Add hours-worked formulas to this schedule, handle overnight shifts, subtract break minutes, and flag anyone over 40 hours"
Griddy can add the formulas, fix the formatting, and make the weekly review easier before the schedule is published.
Skip the manual work
Describe it. Griddy does it.
Instead of writing this formula yourself, just tell Griddy what you need in plain English. Works in Excel and Google Sheets.
Use this on real templates
Keep hours visible before the schedule is published
Hours-worked formulas make schedule reviews more useful because managers can see weekly load, overtime risk, and staffing balance before sending the rota.
Employee Schedule
Plan a weekly staff rota with day-by-day shifts, weekly hours, overtime flags, and a manager snapshot block. Free template for teams, shops, and clinics.
Open templateHREmployee Schedule for Small Business
Plan weekly shifts, hours, days off, and coverage for a small business team in one free employee schedule spreadsheet.
Open templateHREmployee Schedule for Restaurants
Plan restaurant shifts, opens, closes, stations, and coverage in one free staff schedule spreadsheet built for restaurants and cafes.
Open templateHREmployee Schedule for Retail
Plan retail shifts, store coverage, opens, closes, and weekend staffing in one free employee schedule spreadsheet built for store teams.
Open templateHRVacation Tracker
Track PTO balances, upcoming leave, and coverage risk for the whole team in one shared staffing sheet. Keep low balances, approved trips, and summer planning visible without HR software.
Open template