You're probably staring at a sheet where the math should be simple. Start time in one cell, end time in another, subtract one from the other, done. Instead Excel gives you a decimal, a weird time, or a row of ####.
That's the point where it's often assumed Excel is being difficult for no reason. It isn't. It's being extremely literal. Once you understand that, calculating hours in Excel gets much easier, especially when you need to handle overnight shifts, unpaid breaks, weekly totals, or pay bands like late-night premiums.
Table of Contents
- Why Calculating Hours in Excel Is So Tricky
- The Essentials Entering and Calculating Basic Hours
- Mastering Overnight Shifts and Negative Times
- Subtracting Breaks and Summing Totals Over 24 Hours
- Advanced Scenarios Calculating Unsocial Hours
- Troubleshooting Common Errors and A Free Template
Why Calculating Hours in Excel Is So Tricky
The single idea that makes time formulas click is this: Excel stores time as a fraction of a 24-hour day. Microsoft documents that if you subtract one time from another, Excel returns a day-based value, and you convert that result into hours by multiplying by 24, into minutes by 1440, and into seconds by 86400 in its guide to calculating the difference between two times in Excel.
That sounds abstract until you see what it means in practice. Noon is half a day, so Excel treats it like 0.5. A full day is 1. A short duration is just a smaller slice of that day.

Excel stores time as part of a day
This is why a formula can be correct and still look wrong. If you enter a start time in A2 and an end time in B2, =B2-A2 returns a duration in day units. Excel may display that result as a time if the cell is formatted that way, or as a decimal if it's formatted as General or Number.
Practical rule: If the result needs to look like a duration, format the cell as time. If the result needs to become payroll-ready decimal hours, convert it with math.
That distinction matters more than people think. Teams using manual spreadsheets for invoicing often need decimal hours, while people reviewing a schedule usually want a readable duration. If your process goes beyond a basic sheet, dedicated time tracking software for billable hours can reduce a lot of this friction, but Excel still does the job well when the formulas are set up properly.
Why cells show decimals or
#### usually means the display format can't show what Excel thinks is in the cell. Sometimes the column is too narrow. Sometimes the result is effectively negative time, which standard Excel time formatting doesn't handle well.
A lot of routine reporting gets messy for the same reason. One person enters a time as text, another uses a date-time value, and a third copies data from somewhere else. If your schedule also involves people in different regions, a separate time zone meeting scheduler guide helps clean up a different but related layer of confusion.
The Essentials Entering and Calculating Basic Hours
The cleanest timesheet starts with clean input. If Excel doesn't recognize your entries as actual times, even a perfect formula will fail.

Enter time in a way Excel recognizes
Use entries like these:
- AM and PM format:
9:00 AM,5:30 PM - 24-hour format:
09:00,17:30 - Consistent column types: keep the whole Start column and End column formatted as Time
What doesn't work well is mixing formats in the same sheet. If one row contains real times and another contains text that only looks like a time, the formulas won't behave consistently.
A simple layout works best:
| Column | Purpose |
|---|---|
| A | Date |
| B | Start time |
| C | End time |
| D | Hours worked |
Use one formula for duration and another for decimal hours
For a standard same-day shift, the core method is straightforward. The practical formula is =(EndTime-StartTime)*24, because Excel stores time as fractions of a day and you need that conversion to get hour units, as shown in this explanation of an Excel timesheet formula.
If your start time is in B2 and end time is in C2, use:
=(C2-B2)*24
That gives you decimal hours. If the shift is eight hours and thirty minutes, the result becomes 8.5.
If you want the result to display as a duration instead, use:
=C2-B2
Then format the result cell as a time duration. For practical sheet building, I usually separate the two:
- One column for display duration
- One column for decimal hours for billing or payroll
That avoids constant reformatting.
Keep the value and the display separate in your head. Formatting changes how a result looks. Multiplying by 24 changes what unit the result represents.
This matters a lot for freelancers, assistants, and solo operators who export data into invoices or weekly summaries. Many people bundle that with broader admin systems and lightweight productivity tools for freelancers, but the spreadsheet itself still needs the correct formula underneath.
Mastering Overnight Shifts and Negative Times
Same-day math is easy. Overnight math is where most timesheets break.
If someone starts at 10:00 PM and ends at 6:00 AM, plain subtraction returns a negative duration because the end time is technically smaller than the start time when Excel looks only at the clock values.

Why overnight shifts break the basic formula
A basic formula like =C2-B2 assumes both times belong to the same day. Overnight shifts don't. That's why you often get a bad result or ####.
This isn't a fringe case. Anyone handling rota schedules, care staffing, maintenance windows, hospitality, or support coverage runs into it constantly. It also shows up in personal planning if you track study blocks, side work, or recurring routines that drift later into the evening, which is why many people also lean on broader time management tools for work outside Excel.
Two formulas that fix overnight calculations
The compact fix is:
=MOD(C2-B2,1)*24
MOD(...,1) wraps a negative time difference back into the correct portion of a day. It's concise and reliable.
The more explicit version is:
=IF(C2<B2,(C2+1)-B2,C2-B2)*24
This tells Excel that if the end time is earlier than the start time, add one day to the end time before subtracting.
Here's the trade-off:
| Formula | Best for | Trade-off |
|---|---|---|
=MOD(C2-B2,1)*24 |
Compact sheets | Less obvious to beginners |
=IF(C2<B2,(C2+1)-B2,C2-B2)*24 |
Shared workbooks | Longer, but easier to read |
If other people will inherit the workbook, the IF version is often safer. If you maintain the file yourself, MOD is cleaner.
A quick visual walkthrough helps if you want to see the logic in action:
When to use MOD and when to use IF
Use MOD when your workbook is formula-heavy and you want fewer moving parts. Use IF when the spreadsheet will be opened by managers, clients, or teammates who need to inspect formulas and understand them fast.
What doesn't work is trying to patch overnight shifts with manual edits like adding estimated hours directly into a total column. That always comes back to bite you later when someone changes a start time and forgets to update the override.
Subtracting Breaks and Summing Totals Over 24 Hours
A usable timesheet has to do two things well. It must remove unpaid breaks correctly, and it must total hours without rolling over like a clock.

Subtract break time without breaking the sheet
There are two practical ways to handle breaks.
If you store breaks as a duration, such as 0:30 for a thirty-minute unpaid lunch, use:
=(MOD(C2-B2,1)-D2)*24
In this setup:
- B2 is start time
- C2 is end time
- D2 is break duration
If you track break minutes as a plain number, convert the minutes into part of a day before subtracting:
=(MOD(C2-B2,1)-(D2/1440))*24
That second version is often better for staff sheets because people understand entering 30 more easily than entering 0:30.
A practical setup looks like this:
| Column | Example content |
|---|---|
| B | Start |
| C | End |
| D | Break minutes |
| E | Paid hours |
Then E2 becomes:
=(MOD(C2-B2,1)-(D2/1440))*24
Why weekly totals reset unless you format them correctly
This catches people all the time. You total daily durations with SUM, and the answer looks wrong because Excel displays it like a clock, not an accumulated duration.
If your daily values are stored as time durations, the sum formula is simple:
=SUM(E2:E8)
The issue is display. A total greater than a full day can look like it has wrapped around instead of showing the full number of hours. The fix is custom formatting with:
[h]:mm
Square brackets tell Excel to keep accumulating hours instead of resetting after a full day.
Standard time formatting answers the question “what time is it?”
[h]:mmanswers the question “how long did this take in total?”
That distinction matters in payroll, contractor logs, volunteer summaries, and weekly admin sheets. If you skip the format step, your formula may be right while your report looks wrong.
Advanced Scenarios Calculating Unsocial Hours
Most tutorials stop after start minus end. Real payroll work doesn't.
One of the most useful but neglected Excel problems is calculating unsocial hours, meaning the part of a shift that falls inside a premium window such as late night. This is an underserved area in Excel help content, especially for accountants and PMs who need recurring reminders and accurate shift-based compensation, as reflected in searches around Excel unsociable hours calculations.
A formula for overlap inside a pay window
Assume:
- Shift start is in
B2 - Shift end is in
C2 - Unsocial window starts at
10:00 PM - Unsocial window ends at
6:00 AM
The cleanest approach is to work with full date-time values when possible. Then calculate the overlap between the worked shift and the premium window using MAX and MIN.
A common pattern looks like this:
=(MIN(ShiftEnd,WindowEnd)-MAX(ShiftStart,WindowStart))*24
That formula returns the overlapping portion only. If there's no overlap, you'll want to wrap it so it doesn't return a negative result:
=MAX(0,MIN(ShiftEnd,WindowEnd)-MAX(ShiftStart,WindowStart))*24
The logic is solid:
MAX(ShiftStart,WindowStart)finds the later of the two start pointsMIN(ShiftEnd,WindowEnd)finds the earlier of the two end points- Subtracting those gives the shared time only
This is the same mental model I use whenever a spreadsheet needs to answer, “How much of one time range sits inside another?”
How to adapt it for recurring routines
This overlap method is also useful outside payroll. If someone follows a recurring routine but the start time shifts slightly from day to day, you can still total only the part that falls inside a target window.
That matters because recurring routine calculations are another under-served corner of spreadsheet work. Static examples are easy. Real life isn't static. A cleaner, assistant, freelancer, or student may start a little earlier or later each day, yet still need a reliable total without editing formulas every week.
For those sheets, the best practice is simple:
- Store true date-time values when shifts may cross midnight
- Use helper columns for window start and window end
- Calculate overlap once, then copy down
- Avoid manual adjustments to individual rows
Troubleshooting Common Errors and A Free Template
Most Excel time problems come from a small set of repeat mistakes. When you know what to check, they're usually quick to fix.
Fast fixes for the errors people hit most often
-
####in the result cell
The column may be too narrow, or the formula may be producing a negative time. Widen the column first. If that doesn't fix it, switch to an overnight-safe formula. -
#VALUE!error
One or more time cells are probably text, not real times. Re-enter them in a consistent format and check the cell format. -
Weekly totals look too small
The total may be correct but displayed with normal time formatting. Change the total cell to[h]:mm. -
Overnight rows work sometimes and fail sometimes
That usually means the sheet mixes same-day formulas and overnight shifts. Standardize the whole column with one formula approach.
If you want another practical walkthrough focused specifically on handling overnight shifts with Excel, that reference is useful for checking your setup against a second example.
A template beats rebuilding the same formulas every week
The fastest way to avoid formula drift is to keep one master worksheet with:
- Start and end time columns
- A break field
- An overnight-safe hours formula
- A weekly total formatted as
[h]:mm - A separate decimal-hours column for payroll
If you're building recurring study or admin routines around that, a simple weekly study schedule template can pair well with the spreadsheet so you're not recreating the same structure every time.
Use the formulas from this article as your base template. Once they're in place, protect the formula cells and only leave input cells editable. That one step prevents a lot of accidental damage.
If you like having repeatable systems instead of rebuilding small workflows every week, Recurrr is a useful hidden gem. It isn't a full project management suite, and it doesn't try to be. It's a lightweight productivity tool for automating recurring routines, reminders, and everyday follow-ups so the small tasks stop slipping through the cracks.