Excel and Google Sheets how-to
Calculate hours worked from start and end times
A shift from 9:00 to 17:30 is 8.5 hours, but subtract the times and the cell shows 8:30. One small change turns it into a number you can add up and multiply by a pay rate.
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Day | Start | End | Hours |
| 2 | Mon | 9:00 | 17:30 | 8.5 |
| 3 | Tue | 8:15 | 12:45 | 4.5 |
| 4 | Wed | 13:00 | 16:15 | 3.25 |
| 5 | Thu | 7:45 | 16:00 | 8.25 |
| 6 | Fri | 9:00 | 15:00 | 6 |
Sample data. Start times in B and end times in C, typed as times. D2 holds =(C2-B2)*24, filled down to row 6.
The formula
Type the start and end as times, like 9:00 and 17:30. Click D2 and type:
=(C2-B2)*24D2 shows 8.5. Fill it down: Tuesday gives 4.5 and Wednesday 3.25, so a quarter hour shows as .25.
- C2-B2 is the end minus the start.
- *24 turns that into hours, because the spreadsheet counts time in days.
- The brackets make it subtract first.
Why it shows 8:30 or 12:00
Excel and Google Sheets store a time as part of a day: 6:00 is 0.25 and 12:00 is 0.5. So =C2-B2 gives 0.354167, part of a day, and the app shows it as the time 8:30. It reads fine, but it is not 8.5 hours, and 8:30 times a pay rate gives a wrong answer.
Times 24 fixes the number. If the cell still looks like a time, for example 12:00 where you expect 8.5, the cell kept a time format. Format it as a number: in Excel, Home > Number Format > Number; in Google Sheets, Format > Number > Number.
Leave out the brackets and it goes wrong
=C2-B2*24gives -8.27. Multiplying comes before subtracting, so the app works out B2*24 first (9:00 times 24 is 9) and takes that away from 0.73, the stored value of 17:30. Keep the brackets: =(C2-B2)*24.
Shifts that end after midnight
A night shift from 22:00 to 6:00 ends the next day, so the end time is smaller than the start, and =(C2-B2)*24 gives -16. MOD adds the missing day:
=MOD(C2-B2,1)*24That gives 8. For a day shift MOD changes nothing: 9:00 to 17:30 still gives 8.5, so one formula covers every row, for any shift shorter than 24 hours.
Take off an unpaid break
Put the break in minutes in E2, for example 30, and take it off the hours:
=(C2-B2)*24-E2/609:00 to 17:30 with a 30 minute break gives 8. Dividing by 60 turns minutes into hours. If you type the break as a time instead (0:30), take it off before you multiply: =(C2-B2-E2)*24 gives the same 8.
Pay for the day and the week
Put the hourly rate in F1, for example 18.50, then:
=D2*$F$1Monday pays 157.25. The dollar signs keep F1 fixed when you copy the formula down. Add up the week:
=SUM(D2:D6)gives 30.5 hours, and =SUM(D2:D6)*$F$1 gives 564.25 for the week.
Week totals over 24 hours
If you keep hours as times (8:30) instead, a week total needs one more step. Add up the five days and 30 hours 30 minutes shows as 6:30, because a time format starts again after each 24 hours. Give the total cell the custom format [h]:mm and it shows 30:30. In Excel: right-click, Format Cells, Custom, then type [h]:mm. In Google Sheets: Format > Number > Duration, which shows 30:30:00.
For pay, hours as a number are easier: multiply the time total by 24 and you get 30.5.
Free practice sheet
Try it on three everyday jobs: hours from start and end times, night shifts that end after midnight, and pay after an unpaid break with a week total. Each tab has yellow cells to fill in and a Check column that says Correct or Try again as you type, plus an Answers tab. One Excel file that opens in Google Sheets too. Free, no sign up. Sample data.
Download the practice sheet (.xlsx, 10 KB)
Watch it in 23 seconds
Templates with the math already done
Rather skip the formulas? These templates come with every formula built and checked, plus a filled-in sample.
- Timesheet and Pay TrackerType the hours you work each day and check your paystub, for hourly workers paid every two weeks.
- Employee Schedule TemplateWeekly shifts for each person with hours, overtime and labour cost.
- Invoice Template and TrackerInvoices with a payment tracker for paid and overdue.
Teaching this to a class or team?
More how-tos
- Find a price by its code with XLOOKUPType a product code, get its price back from your price list. One formula, no helper columns.
- Total each category with SUMIFSAdd up all the Fuel, all the Office, all the Meals: one formula per category, and more rules when you need them.
- Check two conditions at once with IF and ANDFree shipping only when the order is 50 or more and ships in Canada: one IF, one AND, done.
- Add leading zeros to numbersType 00021 and Excel or Google Sheets shows 21, because to them it is just the number 21. Here is how to get the zeros back, and keep them.
- Fix #DIV/0! in an averageAn average of nothing is a division by zero, so AVERAGE shows #DIV/0! until the first number arrives. One IF fixes it.
- Count rows that meet two conditions with COUNTIFSHow many of Ana's deals were 500 or more? COUNTIFS answers it in one cell, and takes as many rules as you need.
- Calculate percentage changeSales went from 400 to 500. That is a 25% increase, and one short formula works it out for every row.
- Calculate years of service from a start dateAna started on 15 March 2019. How many full years has she worked? DATEDIF counts them, and the same formula works out an age from a date of birth.
- Combine first and last name into one cellFirst names in one column, last names in the next, and you need "Ana Lopez" in one cell. The & sign joins them.
- Find duplicates in a list with COUNTIFA mailing list where some people signed up twice. One formula shows how many times each email appears, so the repeats stand out.
- Split a full name into first and last nameYour list has "Ana Lopez" in one cell and you need Ana and Lopez in two. Two short formulas find the space and split there.
- Total amounts by month with SUMIFSA list of dated expenses and you want one total per month. SUMIFS adds every amount between the first and the last day of the month.
- Count working days between two datesAna is off from 1 Oct to 14 Oct. How many working days is that? NETWORKDAYS counts Monday to Friday and leaves out the weekends.
- Hide #N/A in VLOOKUP with IFERRORYour order list has a code that is not in the price list, and VLOOKUP shows #N/A. IFERROR puts your own words there instead.
- Count cells that contain textA stock list where some items have a note and most do not. One COUNTIF with an asterisk counts the notes and skips the empty cells.
- Make a running total (cumulative sum)Monthly sales in one column, the total so far in the next. One formula, filled down.
- Round to 2 decimal places, up or downA 15% discount turns 12.99 into 11.0415. ROUND makes it 11.04 and keeps your totals right to the cent. ROUNDUP and ROUNDDOWN handle the times when nearest is the wrong answer.
- How long to $1,000,000? FV and NPERPut $500 a month away at an example 7% a year. FV says what it grows to, NPER says when it passes $1,000,000. Two formulas, no calculator site.
- Why your formula gives the wrong number: the order of operationsA2 holds 10 and A3 holds 4. What does =A2-A3*2 give? It is 2, not 12. The same rule explains most formulas that look right and give the wrong number.
- Why your SUM says 0, and how to fix itThe amounts are right there in the column, and the total says 0. They look like numbers, but the sheet has them stored as text, and SUM skips text.
- Fill handle not working? Copy a formula down fastYou wrote one formula and need it in every row. Here are the quick ways to copy it down, and what to check when the fill handle will not show up or the copies come out wrong.
- IF a cell is blank, or not blankYou want a formula to do one thing when a cell is empty and something else when it is filled. Two double quotes do the job, and they also catch the blanks ISBLANK misses.
- Formulas not updating? Recalculate and refreshYou change a number and the total does not move. It is nearly always one of a handful of things, and each one takes seconds to fix once you know which.
- Standard deviation in Excel and Google SheetsTwo shops both average 40 orders a day. One sells 38 to 42 every day; the other swings from 25 to 55. The average cannot tell them apart. The standard deviation can.
- Stack several columns into one column with TOCOLNames in three columns, one for each day, and you need them in one list. One formula does it, and the list keeps up when the columns change.
- Long numbers turn into E+ or end in 0 in ExcelYou type a 12 digit order number and Excel shows 5.93774E+11. You type a 16 digit account number and the last digit turns into 0. The first one is only how the cell looks. The second is a real loss, and it has to be stopped before you type.
- Count how many times each value appears in a columnA staff list with a department on every row, and you need to know how many people are in each department. Two short formulas build the count table, and it keeps up when the list changes.
- Free pricing calculatorsPrice a job from your real costs and margin. No sign up.
- Free downloadsPractice sheets and printable pages, no email and no sign up.







