Enter the start and end times. If you enter a break in minutes, the hours worked after the break are calculated at the same time.
Table of Contents
-
What you can do on this page
-
What is this calculation used for?
-
How to Use
-
Formula
-
Symbols and terms
-
Good to know before you start
-
How to calculate it in Excel
-
How to calculate it in Google Sheets
-
How to calculate it in Python
-
How to write it in LaTeX and other math languages (copy and paste)
-
How to have ChatGPT do the calculation
-
DataChef Features
-
Related Features
-
NumberChef Calculators List
What you can do on this page
- Enter a start time and an end time, such as 9:00 AM to 5:30 PM, and you get the time in between (the shift length) right away
- Enter a break in minutes, and the hours worked after the break are calculated at the same time
- The result also shows decimal hours, such as 7 h 30 min → 7.5 hours, which you can multiply by an hourly wage as is, and the total minutes worked
- Overnight shifts where the end time is earlier than the start time, such as 10:00 PM to 6:00 AM, are calculated too
- A plain-language explanation of the formulas and copy-and-paste formulas for Excel, Google Sheets and Python are all on this page
What is this calculation used for?
For a shift from 9:00 AM to 5:30 PM with a 1-hour unpaid lunch break, you work 7 hours 30 minutes, which is 7.5 decimal hours. At $18 an hour, that is \(18 \times 7.5 = 135\) dollars.
If you write "7 hours 30 minutes" as "7.3 hours", the pay comes out wrong. Knowing just this one conversion, dividing the minutes by 60, lets you check your pay stub and estimate what a shift will earn.
For payroll, a business takes each day's clock-in and clock-out times, finds the shift length, subtracts unpaid breaks, and adds up the hours worked for each pay period. For example, 8 + 8 + 7.5 + 8 + 8.5 = 40 hours in a week.
Time clock apps do the same thing inside: turn times into minutes, subtract, and take away breaks, over and over. For paper time cards or a small shop's schedule, knowing this method is enough to do it with a calculator and a notepad.
For a night shift from 10:00 PM to 6:00 AM, the numbers alone give "6 − 22", which is negative. Add one day of 24 hours (1440 minutes) and you see it is an 8-hour shift.
In jobs with night shifts, such as nursing, care work, factories and 24-hour stores, time that crosses midnight is an everyday calculation. Once you know how it works, you can check that the hours on your schedule are right.
In the US, hourly (non-exempt) workers are generally paid overtime at 1.5 times their regular rate for hours over 40 in a workweek, under the federal Fair Labor Standards Act (FLSA). Some states, such as California, also count hours over 8 in a single day. If you work 8:00 AM to 5:30 PM with a 30-minute break, that is 9 hours a day, and 45 hours over 5 days, which is 5 hours over 40. At $20 an hour, those 5 hours pay \(20 \times 1.5 \times 5 = 150\) dollars.
Being able to work out your hours correctly helps you notice when you are working too much and check the hours your overtime pay is based on. (The exact rules depend on your state, your job and your employer, so check with them for details.)
If you study from 7:15 PM to 9:45 PM, that is 2 hours 30 minutes of study for the day. Write down the start and end times, and you can add up each day's total later with this same subtraction.
Study logs for an exam, time logs for freelance or remote work, and more: turning "from when to when" into "how many hours" is something you do almost every day, not only at work.
Formula
Symbols and terms
Symbols
| \(h\), \(m\) | h, m | The hour (\(h\)) and minute (\(m\)) of a time of day, on the 24-hour clock (example: for 5:30 PM, \(h = 17\) and \(m = 30\)). They stand for "hour" and "minute". |
| \(T\) | T | A time of day turned into minutes after midnight, found with \(T = 60h + m\). (Example - 17:30 → 1050 minutes) |
| \(T_1\), \(T_2\) | T sub 1, T sub 2 | The start time in minutes (\(T_1\)) and the end time in minutes (\(T_2\)). (Example - 9:00 → \(T_1 = 540\), 17:30 → \(T_2 = 1050\)) |
| \(E\) | E | The shift length (the time from start to end) in minutes. E stands for "elapsed". |
| \(B\) | B | The break in minutes. B stands for "break". |
| \(W\) | W | The hours worked (the shift length minus the break, the time you actually worked) in minutes. W stands for "work". |
| \(H\) | capital H | The hours worked as a decimal number of hours (decimal hours), found with \(H = W \div 60\). Do not mix it up with the small \(h\) (the hour of a time of day). (Example - 450 minutes → 7.5 hours) |
| \(1440\) | one thousand four hundred forty | The number of minutes in 1 day: \(24 \times 60 = 1440\). It is added for an overnight shift (one that started the day before). |
Terms
| time of day | A point in time, such as 9:00 AM. It is different from a length of time, such as 8 hours 30 minutes. This page finds the length of time between two times of day. |
| length of time | How long something lasts, such as 8 hours 30 minutes. It is different from a time of day, such as 9:00 AM. This page finds the length of time between two times of day. |
| 24-hour clock | A way of writing times of day with hours from 0 to 23, sometimes called military time in the US. Add 12 to PM hours (5:30 PM → 17:30, 10:00 PM → 22:00). Midnight is 0:00, and noon stays 12:00. |
| shift length | The whole time from the start time to the end time, breaks included. At work, it is the time you spend on the job from clocking in to clocking out. |
| hours worked | The shift length minus the break, the time you actually worked. For hourly workers, pay is normally based on these hours. (Unpaid meal breaks are taken out; short rest breaks are usually counted as paid time, so do not subtract them.) |
| decimal hours | Time written as a decimal, such as 7 hours 30 minutes = 7.5 hours. The minutes are divided by 60, so the value can be multiplied by an hourly wage as is. Note that 7 hours 30 minutes is not 7.3 hours. Payroll systems and time clocks in the US often show hours this way. |
| overnight shift | A shift during which the date changes, such as a night shift. The end time is a smaller number than the start time, so one day, 1440 minutes, is added in the calculation. |
| base 60 | Counting in groups of 60, where 60 of one unit make 1 of the next unit up. Sixty minutes make 1 hour. It is easy to make mistakes when this is mixed with ordinary decimals (base 10), so this calculator first puts everything into minutes. |
Good to know before you start
Here is what helps you use the calculation on this page with real understanding, not just by pressing the button.
If you get stuck, going back over these topics is the fastest way forward.
| Time of day and elapsed time (Grades 2–3) |
|
| AM, PM and the 24-hour clock (Grades 2–3) |
|
| Subtraction with regrouping and division with remainders (Grades 3–4) |
|
| Decimals (Grades 4–5) |
|
How to calculate it in Excel
| Hour (24-hour clock) | 17 |
| Minute | 30 |
| Time in minutes | =B1*60+B2 |
| Start: hour (24-hour clock) | 9 |
| Start: minute | 0 |
| End: hour (24-hour clock) | 17 |
| End: minute | 30 |
| Start in minutes | =B1*60+B2 |
| End in minutes | =B3*60+B4 |
| Shift length (min) | =IF(B6<B5,B6-B5+1440,B6-B5) |
| Shift: hours | =QUOTIENT(B7,60) |
| Shift: minutes | =MOD(B7,60) |
| Shift length (min) | 510 |
| Break (min) | 60 |
| Hours worked (min) | =B1-B2 |
| Worked: hours | =QUOTIENT(B3,60) |
| Worked: minutes | =MOD(B3,60) |
| Decimal hours | =ROUND(B3/60,2) |
In the second table, enter the start and end times in B1 to B4. B5 and B6 turn them into minutes (540 and 1050), and B7 shows the shift length (510 minutes). The IF function adds 1440 when the end is the smaller number, so overnight shifts (for example, start 22, end 6) also come out right. B8 and B9 split the minutes into hours and minutes with QUOTIENT (the whole-number part of a division) and MOD (the remainder). The answer is 8 hours 30 minutes.
In the third table, enter the shift length in minutes in B1 and the break in minutes in B2. B3 shows the minutes worked (450), B4 and B5 split them into 7 hours 30 minutes, and B6 shows the decimal hours (7.5; ROUND rounds to 2 decimal places when the division does not come out even). Multiply your hourly wage by B6 to get the pay. Just replace the values in column B with your own.
How to calculate it in Google Sheets
| Hour (24-hour clock) | 17 |
| Minute | 30 |
| Time in minutes | =B1*60+B2 |
| Start: hour (24-hour clock) | 9 |
| Start: minute | 0 |
| End: hour (24-hour clock) | 17 |
| End: minute | 30 |
| Start in minutes | =B1*60+B2 |
| End in minutes | =B3*60+B4 |
| Shift length (min) | =IF(B6<B5,B6-B5+1440,B6-B5) |
| Shift: hours | =QUOTIENT(B7,60) |
| Shift: minutes | =MOD(B7,60) |
| Shift length (min) | 510 |
| Break (min) | 60 |
| Hours worked (min) | =B1-B2 |
| Worked: hours | =QUOTIENT(B3,60) |
| Worked: minutes | =MOD(B3,60) |
| Decimal hours | =ROUND(B3/60,2) |
How to calculate it in Python
# Start time and end time (24-hour clock) and break (minutes)
start_hour, start_minute = 9, 0
end_hour, end_minute = 17, 30
rest_minutes = 60
start_total = start_hour * 60 + start_minute # start time in minutes
end_total = end_hour * 60 + end_minute # end time in minutes
elapsed_minutes = end_total - start_total # shift length (minutes)
if elapsed_minutes < 0:
# end is earlier than start -> the shift started the day before (overnight), so add one day
elapsed_minutes += 1440
work_minutes = elapsed_minutes - rest_minutes # hours worked (minutes)
decimal_hours = round(work_minutes / 60, 2) # decimal hours (for hourly pay)
def format_minutes(total_minutes):
# turn minutes into the form "8 h 30 min" ("0 h" for 0 minutes)
hours, minutes = divmod(total_minutes, 60)
if hours == 0 and minutes == 0:
return "0 h"
if hours == 0:
return f"{minutes} min"
if minutes == 0:
return f"{hours} h"
return f"{hours} h {minutes} min"
print(f"Shift length: {format_minutes(elapsed_minutes)} ({elapsed_minutes} min)")
print(f"Hours worked: {format_minutes(work_minutes)} ({work_minutes} min)")
print(f"Decimal hours: {decimal_hours} h")
How to write it in LaTeX and other math languages (copy and paste)
T = 60h + m
T = 60h + m
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>T</mi><mo>=</mo>
<mn>60</mn><mi>h</mi>
<mo>+</mo><mi>m</mi>
</mrow>
</math>
T = 60h + m
totalMinutes = 60*h + m
T := 60*h + m;
T = 60*h + m;
T = 60h + m
E = T₂ − T₁ (T₂ ≥ T₁), E = T₂ − T₁ + 1440 (T₂ < T₁)
E = T_2 - T_1 \quad (T_2 \ge T_1), \qquad E = T_2 - T_1 + 1440 \quad (T_2 < T_1)
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>E</mi><mo>=</mo>
<msub><mi>T</mi><mn>2</mn></msub><mo>−</mo>
<msub><mi>T</mi><mn>1</mn></msub>
<mo>,</mo><mspace width="0.7em"/>
<mi>E</mi><mo>=</mo>
<msub><mi>T</mi><mn>2</mn></msub><mo>−</mo>
<msub><mi>T</mi><mn>1</mn></msub>
<mo>+</mo><mn>1440</mn>
</mrow>
</math>
E = T_2 - T_1, E = T_2 - T_1 + 1440
elapsedMinutes = If[t2 >= t1, t2 - t1, t2 - t1 + 1440]
E := `if`(t2 >= t1, t2 - t1, t2 - t1 + 1440);
if t2 >= t1, E = t2 - t1; else, E = t2 - t1 + 1440; end
E = T_2 - T_1 (T_2 ≥ T_1), E = T_2 - T_1 + 1440 (T_2 < T_1)
W = E − B, H = W ÷ 60
W = E - B, \quad H = \dfrac{W}{60}
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mrow>
<mi>W</mi><mo>=</mo>
<mi>E</mi><mo>−</mo><mi>B</mi>
<mo>,</mo><mspace width="0.7em"/>
<mi>H</mi><mo>=</mo>
<mfrac><mi>W</mi><mn>60</mn></mfrac>
</mrow>
</math>
W = E - B, H = W / 60
workMinutes = elapsedMinutes - restMinutes; decimalHours = workMinutes / 60
W := E - B; H := W / 60;
W = E - B; H = W / 60;
W = E - B, H = W / 60
How to have ChatGPT do the calculation
You are a work hours calculation assistant. Do the following calculation by actually running Python code, and base your answer only on the numbers from the execution result (do not answer by mental math or guessing). A shift starts at 9:00 and ends at 17:30 (both on the 24-hour clock, on the same day), with a 60-minute break. Find each of the following: 1. The shift length (the time from start to end, in the form "X hours Y minutes") 2. The hours worked (the shift length minus the break, in the form "X hours Y minutes") 3. The hours worked as decimal hours (the minutes worked divided by 60) and as total minutes Turn each time into minutes with "60 × hour + minute" before subtracting. If the end time is earlier than the start time, treat the shift as starting the day before (overnight) and add 1440 minutes. Show the formulas you used and the numbers from the execution result.
How to Use
-
1Enter your numbersType the numbers you want to calculate with into the input fields
-
2CalculatePress the "Calculate" button
-
3Check the resultThe result appears on the spot. The same page also explains the idea behind the calculation and the formula
DataChef Features
No technical knowledge required.
Intuitive and user-friendly operation.
Can be used without registering personal information.
Automatic file deletion by clicking "download".
and rapid file conversion.
No attribution required.
No need to contact us for commercial use permission.
