Split First and Last Name in Excel — With Examples (TEXTSPLIT, LEFT, FIND)
Learn how to split first and last name in Excel: TEXTSPLIT, LEFT and FIND formulas, middle names, Flash Fill and Text to...
Read Guide →You have a start time and an end time, and you need the hours between them — for a timesheet, a shift, or a deadline. The rule behind every time formula is the same as the rule behind every date formula: a time is a number. One full day is 1, so 3:00 PM is 0.625 — 15 out of 24 hours — and 2:30 PM is 0.604167. That is why subtraction works: the difference between two times is a fraction of a day, and multiplying it by 24 turns it into hours. The two things that catch everyone are the format — h:mm wraps at 24 hours, so a 30-hour total shows as 6:00 — and the night shift, which goes negative unless you add a day. This guide gives you the formula first, works it through on a five-day shift table with a night shift in it, and covers overtime and adding hours.
Quick takeaway: a time is a fraction of a day — that is why subtraction works.
=B2 - A2 — the difference, as a fraction of a day.=(B2 - A2) * 24 — the total hours, as a number you can add up.=(B2 - A2) * 1440 — the total minutes.=(B2 - A2) * 86400 — the total seconds.[h]:mm shows a total over 24 hours. h:mm wraps at 24.+1 or MOD, or it goes negative.
=B2 - A2
=(B2 - A2) * 24
| What you want | Formula | Result for 10:35 AM → 3:30 PM |
|---|---|---|
| The difference as a time | =B2 - A2 | 4:55 |
| The total hours | =(B2 - A2) * 24 | 4.9167 |
| The total minutes | =(B2 - A2) * 1440 | 295 |
| The total seconds | =(B2 - A2) * 86400 | 17,700 |
| The hours part only | =HOUR(B2 - A2) | 4 |
| The minutes part only | =MINUTE(B2 - A2) | 55 |
HOUR, MINUTE and SECOND extract the components, and they never exceed 24, 60 and 60 — so HOUR gives 4, not 4.9167. For a total you can add up, multiply: the difference is a fraction of a day, and 24 hours make a day.
| Day | Start | End | Hours | Overtime after 8h |
|---|---|---|---|---|
| Mon | 9:00 AM | 5:30 PM | 8.5 | 0.5 |
| Tue | 9:00 AM | 5:00 PM | 8.0 | 0 |
| Wed | 9:00 AM | 6:00 PM | 9.0 | 1.0 |
| Thu | 10:00 PM | 6:00 AM | 8.0 | 0 |
| Fri | 9:00 AM | 4:30 PM | 7.5 | 0 |
| Week total | 41.0 | 1.5 |
Check the numbers: Monday is 8.5 hours, Tuesday 8, Wednesday 9, Thursday 8 (the night shift, 10 PM to 6 AM), Friday 7.5. The week total is 41 hours, and the overtime — the hours over 8 a day — is 1.5. The formula in the Hours column is =(B2 - A2) * 24, and Thursday uses the overnight version from the next section.
A shift that crosses midnight goes negative with plain subtraction: 6:00 AM minus 10:00 PM is −0.6667 of a day, which is −16 hours. There are two fixes:
=MOD(B2 - A2, 1) * 24
MOD wraps the negative difference back into the day: 6:00 AM minus 10:00 PM, wrapped, is 8 hours. The other fix is to include the date with the time — 10:00 PM on Thursday to 6:00 AM on Friday — and subtract normally. Either way, the answer is 8 hours. The full guide to the days between two dates is the months between dates guide.
=MAX(0, (B2 - A2) * 24 - 8)
MAX(0, …) keeps the answer at zero when the shift is 8 hours or less: Monday gives 0.5, Wednesday gives 1, and Tuesday, Thursday and Friday give 0. The week total is 1.5 hours of overtime. For a weekly overtime rule instead of a daily one, add the week up first and subtract the weekly limit: =MAX(0, SUM(hours) - 40) gives 1 hour on this table.
=A2 + 8/24
To add 8 hours to 9:00 AM, add 8/24 — 8 hours as a fraction of a day — and the answer is 5:00 PM. TIME does the same job: =A2 + TIME(8, 0, 0). The full guide to adding months to a date is the add months to date guide.
| Format | What it shows | Use it for |
|---|---|---|
h:mm | 6:00 for a 30-hour total | A time of day, or a difference under 24 hours |
[h]:mm | 30:00 for a 30-hour total | A total over 24 hours |
h:mm:ss | 4:55:00 | Hours, minutes and seconds |
| Number | 4.9167 | A total you will add up or multiply |
The square brackets are the whole trick: [h] counts hours past 24 instead of wrapping. Without them, a 30-hour week total shows as 6:00, and the timesheet looks wrong. TEXT does the same formatting as text: =TEXT(B2 - A2, "h:mm") gives “4:55”, but the result is text, not a number — so it cannot be added up.
| Mistake | What happens | Fix |
|---|---|---|
| Your answer shows as 9:30 AM instead of 9.5 | The cell is formatted as a time, not a number | Format the cell as Number, or multiply by 24 |
| Your 30-hour total shows as 6:00 | h:mm wraps at 24 hours | Use [h]:mm for totals |
| Your night shift goes negative | The end time is earlier in the day than the start time | Use MOD(B2 − A2, 1), or include the date |
| You used HOUR for the total | HOUR never exceeds 24 — it gives the hours part only | Multiply by 24 for the total hours |
| You used TEXT and then tried to add the results | TEXT returns text, not a number | Use a number format instead, or multiply by 24 |
| Your times are text, not real times | #VALUE! — subtraction cannot read them | Convert them with TIMEVALUE, retype them, or rebuild them with TIME |
| You added 8 to add 8 hours | 8 is 8 days, not 8 hours | Add 8/24, or TIME(8, 0, 0) |
How do I calculate the time difference in Excel? Subtract the start time from the end time: =B2 - A2. For the total hours as a number, use =(B2 - A2) * 24. For 10:35 AM to 3:30 PM, the answer is 4.9167 hours, or 4:55 as a time.
How do I calculate hours between two times in Excel? =(B2 - A2) * 24. The difference is a fraction of a day, and multiplying by 24 turns it into hours. For minutes, multiply by 1,440; for seconds, by 86,400.
How do I show a time total over 24 hours in Excel? Format the cell with [h]:mm. Without the square brackets, h:mm wraps at 24 hours, so a 30-hour total shows as 6:00.
How do I calculate a night shift that crosses midnight? Use =MOD(B2 - A2, 1) * 24, or include the date with the time. For 10:00 PM to 6:00 AM, the answer is 8 hours either way.
How do I calculate overtime after 8 hours in Excel? =MAX(0, (B2 - A2) * 24 - 8). On the shift table in this article, Monday gives 0.5 hours and Wednesday gives 1 hour.
How do I add 8 hours to a time in Excel? =A2 + 8/24, or =A2 + TIME(8, 0, 0). For 9:00 AM, the answer is 5:00 PM.
Why does my time difference show as a time instead of a number? Because the result is a fraction of a day, and the cell is formatted as a time. Format the cell as Number, or multiply by 24 to get the hours.
That is the time difference formula in Excel: subtract, then multiply by 24 for hours, 1,440 for minutes, or 86,400 for seconds — because a time is a fraction of a day. Remember the two things that matter: format a total over 24 hours with [h]:mm, or it wraps and looks wrong, and handle the night shift with MOD or a date, or it goes negative. From here, the next date and time jobs to learn are the ones this formula is built on — the months between dates guide, the add months to date guide, and the day of week formula guide — and the full learning order for the whole site is on the Excel Formulas hub.
Learn how to split first and last name in Excel: TEXTSPLIT, LEFT and FIND formulas, middle names, Flash Fill and Text to...
Read Guide →Learn how to get the month and year from a date in Excel: month name, month number, quarter, first and last day...
Read Guide →Learn how to extract text after a character in Excel: TEXTAFTER and TEXTBEFORE, the last word, and the older FIND method.
Read Guide →