Bookmarks    
nPr and nCr    
Random Number    
SD Calculator    
Sample Size    
Percent Error    
Density    
Molarity    
Molar Mass    
Ohm's Law    
Watts to Amps    
Voltage Drop    
Long Division    
Mixed Numbers    
Rounding    
Nth Root    
Exponents    
Half-Life    
Polar Form    
De Moivre    
3D Distance    
Point to Line    
Cross Product    
Determinant    
Sin Cos Tan    
Triangle Area    
Scale Factor    
Sector Area    
Ellipse Area    
Cube Volume    
Box Volume    
Sphere Volume    
Cone Volume    
Pipe Volume    
Time Duration    
Time Card    
Present Value    
Future Value    
Churn Rate    
A/B Test Calc    
SEO Traffic    
Ideal Weight    
Fat Intake    
Child Height    
Golf Handicap    
Heat Index    
Wind Chill    
Dew Point    
Download Time    
kWh to Cost    
AC Size (BTU)    
Heating Costs    
LED Savings    
Trip Gas Cost    
Tire Size    
Solar Output    
Solar Payback    
Battery Size    
Wall Area    
Gravel Needed    
Mortar Mix    
Slope Grade    
Curtain Size    
Soil Needed    
Sod Needed    
Ramp Length    
Blind Size    
Drain Slope    
Board Feet    
Heat Loss    
Furniture Fit    
Moving Boxes    
Plywood Cuts    
Shelf Sag    
   Add
Probability and random number calculators
Independent Events
Independent Events
Two Events Solver
Two Events Solver
Repeated Trials
Repeated Trials
Bayes' Theorem
Bayes' Theorem
Expected Value
Expected Value
Binomial Distribution
Binomial Distribution
nPr and nCr
nPr and nCr
Circular Permutation
Circular Permutation
With Repetition
With Repetition
Random Number
Random Number
Averages and statistics calculators
Average Calculator
Average Calculator
Mean Median Mode
Mean Median Mode
SD Calculator
SD Calculator
Quartiles & IQR
Quartiles & IQR
Frequency Table
Frequency Table
Correlation (r)
Correlation (r)
Normal Probability
Normal Probability
Z-Score Calculator
Z-Score Calculator
Confidence Interval
Confidence Interval
Sample Size
Sample Size
Mark & Recapture
Mark & Recapture
P-Value Calculator
P-Value Calculator
Percentage and ratio calculators
Percentage Calc
Percentage Calc
Percent Change
Percent Change
Percent Difference
Percent Difference
Percent Error
Percent Error
Ratio Calculator
Ratio Calculator
Discount Calculator
Discount Calculator
Sales Tax Calculator
Sales Tax Calculator
Margin Calculator
Margin Calculator
Speed calculators
Speed Calculator
Speed Calculator
Density and concentration calculators
Density
Density
Molarity
Molarity
Molar Mass
Molar Mass
Physics and electricity calculators
Ohm's Law
Ohm's Law
Watts to Amps
Watts to Amps
Resistor Colors
Resistor Colors
Voltage Drop
Voltage Drop
Unit conversion calculators
Weight Converter
Weight Converter
Shoe Size Converter
Shoe Size Converter
Integer and signed number calculators
Long Division
Long Division
LCM Calculator
LCM Calculator
GCF Calculator
GCF Calculator
Integer Calculator
Integer Calculator
Prime Factorization
Prime Factorization
Diophantine Solver
Diophantine Solver
Modulo Calculator
Modulo Calculator
Factor Calculator
Factor Calculator
Roman Numerals
Roman Numerals
Fraction, decimal and rounding calculators
Fraction Calculator
Fraction Calculator
Mixed Numbers
Mixed Numbers
Simplify Fractions
Simplify Fractions
Fraction to Decimal
Fraction to Decimal
Decimal to Fraction
Decimal to Fraction
Rounding
Rounding
Equation and inequality calculators
Linear Equation
Linear Equation
Linear Systems
Linear Systems
Quadratic Formula
Quadratic Formula
Absolute Value
Absolute Value
Quadratic Inequality
Quadratic Inequality
Polynomial calculators
Binomial Theorem
Binomial Theorem
Square root and nth root calculators
Simplify Radicals
Simplify Radicals
Nth Root
Nth Root
Exponent and logarithm calculators
Exponents
Exponents
Log Calculator
Log Calculator
Number of Digits
Number of Digits
Scientific Notation
Scientific Notation
Sci. Notation Math
Sci. Notation Math
Half-Life
Half-Life
Complex number calculators
Complex Numbers
Complex Numbers
Polar Form
Polar Form
De Moivre
De Moivre
Function and graph calculators
Slope Calculator
Slope Calculator
Linear Function
Linear Function
Direct & Inverse Variation
Direct & Inverse Variation
y = ax² Calculator
y = ax² Calculator
Distance Formula
Distance Formula
3D Distance
3D Distance
Section Formula
Section Formula
Point to Line
Point to Line
Lat/Long Distance
Lat/Long Distance
Complete the Square
Complete the Square
Circle Equation
Circle Equation
Conic Sections
Conic Sections
Polar Coordinates
Polar Coordinates
Sequence calculators
Arithmetic Sequence
Arithmetic Sequence
Geometric Sequence
Geometric Sequence
Fibonacci Sequence
Fibonacci Sequence
Recurrence Relation
Recurrence Relation
Vector calculators
Vector Calculator
Vector Calculator
Cross Product
Cross Product
Matrix calculators
Matrix Calculator
Matrix Calculator
Determinant
Determinant
Inverse Matrix
Inverse Matrix
Plane geometry calculators
Sin Cos Tan
Sin Cos Tan
Degrees ⇔ Radians
Degrees ⇔ Radians
a sin θ + b cos θ
a sin θ + b cos θ
Triangle Solver
Triangle Solver
Triangle Area
Triangle Area
Right Triangle
Right Triangle
Pythagorean Theorem
Pythagorean Theorem
Polygon Angles
Polygon Angles
Scale Factor
Scale Factor
Parallel Lines
Parallel Lines
Rectangle Area
Rectangle Area
Parallelogram Area
Parallelogram Area
Trapezoid Area
Trapezoid Area
Circle Calculator
Circle Calculator
Sector Area
Sector Area
Inscribed Angle
Inscribed Angle
Ellipse Area
Ellipse Area
Solid geometry calculators
Cube Volume
Cube Volume
Cube Surface Area
Cube Surface Area
Box Volume
Box Volume
Box Surface Area
Box Surface Area
Cylinder Volume
Cylinder Volume
Cylinder Surface
Cylinder Surface
Sphere Volume
Sphere Volume
Sphere Surface
Sphere Surface
Spherical Cap Volume
Spherical Cap Volume
Cap Surface Area
Cap Surface Area
Ellipsoid Volume
Ellipsoid Volume
Ellipsoid Surface
Ellipsoid Surface
Pyramid Volume
Pyramid Volume
Pyramid Surface
Pyramid Surface
Cone Volume
Cone Volume
Cone Surface Area
Cone Surface Area
Frustum Volume
Frustum Volume
Frustum Surface Area
Frustum Surface Area
Pipe Volume
Pipe Volume
Capsule Volume
Capsule Volume
Capsule Surface Area
Capsule Surface Area
Date and time calculators
Age Calculator
Age Calculator
Days Between Dates
Days Between Dates
Date Calculator
Date Calculator
Hours From Now
Hours From Now
Day of the Week
Day of the Week
Time Calculator
Time Calculator
Time Zone Converter
Time Zone Converter
Hours Calculator
Hours Calculator
Time Duration
Time Duration
Time Card
Time Card
Finance and economics calculators
Compound Interest
Compound Interest
Simple Interest
Simple Interest
Interest Calculator
Interest Calculator
TVM Calculator
TVM Calculator
Present Value
Present Value
Future Value
Future Value
ROI Calculator
ROI Calculator
IRR Calculator
IRR Calculator
Payback Period
Payback Period
Average Return
Average Return
GDP Calculator
GDP Calculator
Web marketing and ad metric calculators
CTR Calculator
CTR Calculator
Conversion Rate
Conversion Rate
CPC, CPM & CPA
CPC, CPM & CPA
ROAS Calculator
ROAS Calculator
Break-Even CPA
Break-Even CPA
LTV Calculator
LTV Calculator
CAC Calculator
CAC Calculator
Churn Rate
Churn Rate
A/B Test Calc
A/B Test Calc
A/B Sample Size
A/B Sample Size
SEO Traffic
SEO Traffic
Break-Even Point
Break-Even Point
Markup vs. Margin
Markup vs. Margin
CAGR Calculator
CAGR Calculator
Health and fitness calculators
BMI Calculator
BMI Calculator
Sleep Calculator
Sleep Calculator
Calorie Calculator
Calorie Calculator
BMR Calculator
BMR Calculator
TDEE Calculator
TDEE Calculator
Ideal Weight
Ideal Weight
Body Fat Calculator
Body Fat Calculator
Lean Body Mass
Lean Body Mass
Calories Burned
Calories Burned
Protein Intake
Protein Intake
Macro Calculator
Macro Calculator
Carb Calculator
Carb Calculator
Fat Intake
Fat Intake
Child Height
Child Height
Sports calculators
Golf Handicap
Golf Handicap
Pace Calculator
Pace Calculator
1RM Calculator
1RM Calculator
Target Heart Rate
Target Heart Rate
Weather calculators
Heat Index
Heat Index
Wind Chill
Wind Chill
Dew Point
Dew Point
Computer calculators
Base Converter
Base Converter
Subnet Calculator
Subnet Calculator
Download Time
Download Time
Household energy and budget calculators
Electricity Cost
Electricity Cost
kWh to Cost
kWh to Cost
Yearly kWh to Cost
Yearly kWh to Cost
AC Size (BTU)
AC Size (BTU)
AC Running Cost
AC Running Cost
Heating Costs
Heating Costs
Gas vs Electric
Gas vs Electric
LED Savings
LED Savings
Salary Calculator
Salary Calculator
Budget Calculator
Budget Calculator
Car calculators
Trip Gas Cost
Trip Gas Cost
EV Charging Cost
EV Charging Cost
EV vs Gas Cost
EV vs Gas Cost
MPG Calculator
MPG Calculator
Tire Size
Tire Size
Solar power and battery calculators
Solar Output
Solar Output
Solar Panel Count
Solar Panel Count
Solar Payback
Solar Payback
Battery Size
Battery Size
Home and DIY calculators
Tile Calculator
Tile Calculator
Stair Calculator
Stair Calculator
Concrete Volume
Concrete Volume
Wall Area
Wall Area
Wallpaper Rolls
Wallpaper Rolls
Paint Calculator
Paint Calculator
Flooring Needed
Flooring Needed
Exterior Walls
Exterior Walls
Gravel Needed
Gravel Needed
Mortar Mix
Mortar Mix
Slope Grade
Slope Grade
Lumber Cut List
Lumber Cut List
Lot Coverage/FAR
Lot Coverage/FAR
Sheet Vinyl Roll
Sheet Vinyl Roll
Insulation Needed
Insulation Needed
Curtain Size
Curtain Size
TV Size & Distance
TV Size & Distance
Soil Needed
Soil Needed
Sod Needed
Sod Needed
Block Calculator
Block Calculator
Brick Calculator
Brick Calculator
Deck Materials
Deck Materials
Ramp Length
Ramp Length
Pilot Hole Size
Pilot Hole Size
Room Ventilation
Room Ventilation
Paint Thinning
Paint Thinning
Baseboard & Trim
Baseboard & Trim
Blind Size
Blind Size
Picture Hanging
Picture Hanging
Drain Slope
Drain Slope
Screw Calculator
Screw Calculator
Board Feet
Board Feet
Fence Calculator
Fence Calculator
Wood Shrinkage
Wood Shrinkage
Caulk Calculator
Caulk Calculator
Heat Loss
Heat Loss
Furniture Fit
Furniture Fit
Moving Boxes
Moving Boxes
Storage Capacity
Storage Capacity
Plywood Cuts
Plywood Cuts
Shelf Sag
Shelf Sag

Work Hours Calculator (Hours Between Two Times, Minus Breaks)

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.

Enter the hour with AM or PM (5:30 PM is hour "5 PM", minute "30"). The 24-hour clock (hour "17") works too. The start and end hours are required. Blank minutes and a blank break count as 0 minutes. If the end time is earlier than the start time, the shift is treated as an overnight shift that started the day before.
Result
Enter the start time, end time (and break) in the fields on the left and press "Calculate". The result will appear here.

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
Enter the hours with AM or PM, such as "9 AM" or "5 PM" (the 24-hour clock, such as "17", works too). This page calculates a span of less than 24 hours, such as one shift. It cannot be used for spans of two days or more.

What is this calculation used for?

Estimating your pay from an hourly wage (hourly rate × decimal hours)

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.

Adding up time cards for payroll (office and HR)

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.

Counting overnight and shift work correctly (crossing midnight)

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.

Keeping track of overtime (hours over 40 in a week)

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.)

Logging study or project time (self-management)

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

Turning a time of day into minutes after midnight
Standard notation (the usual math form)
\(T\) \(=\) \(60\) \(\times\) \(h\) \(+\) \(m\)
In words (symbols replaced with words)
④ \(T\): time in minutes \(=\) ② \(60\): minutes in 1 hour \(\times\) ① \(h\): hour \(+\) ③ \(m\): minute
The formula in words
① Take the \(h\): hour
② multiply it by \(60\): minutes in 1 hour
③ add the \(m\): minute
④ and you get the \(T\): time in minutes (how many minutes that time is after midnight)
Quick example
5:30 PM (17:30 on the 24-hour clock) in minutes is
time in minutes (1050) \(=\) minutes in 1 hour (60) \(\times\) hour (17) \(+\) minute (30)
\(T = 60 \times 17 + 30 = 1050\)
Key idea
If you try to work out "How many hours from 9:00 AM to 5:30 PM?" with hours and minutes as they are, it is easy to slip up when borrowing, because 1 hour is 60 minutes, not 100. So this calculator first turns each time into one number: how many minutes after midnight it is. Once both times are in minutes, the rest is a plain subtraction. For PM times, add 12 to the hour to get the 24-hour clock before you calculate (5:30 PM → 17:30). The one exception is 12 PM (noon), which stays 12.
Shift length (time from start to end)
Standard notation (the usual math form)
\(E\) \(=\) \(T_2\) \(-\) \(T_1\)
\(E\) \(=\) \(T_2\) \(-\) \(T_1\) \(+\) \(1440\)
In words (symbols replaced with words)
③ \(E\): shift length \(=\) ① \(T_2\): end time in minutes \(-\) ② \(T_1\): start time in minutes
\(E\): shift length \(=\) \(T_2\): end time in minutes \(-\) \(T_1\): start time in minutes \(+\) ④ \(1440\): minutes in 1 day
The formula in words
① Take the \(T_2\): end time in minutes
② subtract the \(T_1\): start time in minutes
③ and you get the \(E\): shift length (the time from start to end)
④ If the end time is earlier than the start time (an overnight shift), the start was on the day before, so add the \(1440\): minutes in 1 day (the second formula)
Quick example
The shift length from 9:00 (540 minutes) to 17:30 (1050 minutes) is
shift length (510 min = 8 h 30 min) \(=\) end time (1050 min) \(-\) start time (540 min)
\(E = 1050 - 540 = 510\)
\(510 = 60 \times 8 + 30\)
Key idea
The subtraction gives a negative number when the end time is the smaller number, as with a shift from 22:00 (10:00 PM) to 6:00 AM the next morning. In that case the shift started the day before (it crossed midnight), so add one day, \(1440\) minutes (\(= 24 \times 60\)), to get the correct time (example: \(360 - 1320 = -960\), and \(-960 + 1440 = 480\) minutes = 8 hours). If the start and end times are the same, this page treats the result as "0 h" (not as a 24-hour shift).
Hours worked and decimal hours (subtracting the break and converting for hourly pay)
Standard notation (the usual math form)
\(W\) \(=\) \(E\) \(-\) \(B\)
\(H\) \(=\) \(W\) \(\div\) \(60\)
In words (symbols replaced with words)
③ \(W\): hours worked \(=\) ① \(E\): shift length \(-\) ② \(B\): break
⑤ \(H\): decimal hours \(=\) \(W\): hours worked \(\div\) ④ \(60\): minutes in 1 hour
The formula in words
① Take the \(E\): shift length
② subtract the \(B\): break
③ and you get the \(W\): hours worked (the time you actually worked)
④ Then divide the hours worked \(W\) by \(60\): minutes in 1 hour
⑤ and you get the \(H\): decimal hours (hours as a decimal, ready to multiply by an hourly wage)
Quick example
With a shift length of 510 minutes (8 h 30 min) and a 60-minute break, the hours worked and decimal hours are
hours worked (450 min = 7 h 30 min) \(=\) shift length (510 min) \(-\) break (60 min)
\(W = 510 - 60 = 450\)
\(H = 450 \div 60 = 7.5\)
Key idea
When you use "7 hours 30 minutes" to calculate pay, the most common mistake is to write it as "7.30". Thirty minutes is half an hour, so as a decimal it is \(0.5\) hours, which makes 7 hours 30 minutes equal to \(7.5\) hours. "Divide the minutes by 60 to get a decimal" is the whole idea of decimal hours. At $18 an hour, the pay is \(18 \times 7.5 = 135\) dollars in one step. The name comes from bridging two ways of counting: hours and minutes count in 60s, while decimals count in 10s. If the minutes do not divide evenly by 60, the decimal goes on forever, so this calculator shows the value rounded to 2 decimal places (example: 16 h 20 min = 980 min → \(980 \div 60 = 16.333\ldots\) → \(16.33\) hours).
The basic method for work hours is: turn the start and end times into minutes, subtract, then take away the break. For an overnight shift, where the end time is earlier, add 1440 minutes. For hourly pay, divide the minutes worked by 60 to get decimal hours (such as 7.5 hours).

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)
  • Knowing the difference between a time of day (a point in time, such as 9:00) and a length of time (such as 8 hours 30 minutes)
  • Knowing that 1 hour = 60 minutes and 1 day = 24 hours
AM, PM and the 24-hour clock (Grades 2–3)
  • Knowing that adding 12 to a PM hour gives the 24-hour clock (5:30 PM → 17:30)
  • Knowing that midnight is the start of the day and is written 0:00 on the 24-hour clock
Subtraction with regrouping and division with remainders (Grades 3–4)
  • Being able to do a written subtraction such as 1035 − 510
  • Being able to find a quotient and remainder, such as 525 ÷ 60 = 8 R 45, to turn minutes back into hours and minutes
Decimals (Grades 4–5)
  • Knowing that 0.5 means one half, and being able to do a division such as 450 ÷ 60 = 7.5
  • Telling apart minutes (base 60) and decimals (base 10), as in 30 minutes = 0.5 hours

How to calculate it in Excel

Copy the whole table below and paste it into cell A1 in Excel. It works as is.
Table to turn a time into minutes
Hour (24-hour clock) 17
Minute 30
Time in minutes =B1*60+B2
Table to find the shift length (works for overnight shifts)
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)
Table to find hours worked and decimal hours
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 first table, enter the hour and minute of a time in B1 and B2, and B3 shows it in minutes (1050 in this example).
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

Copy the whole table below and paste it into cell A1 in Google Sheets. It works as is.
Table to turn a time into minutes
Hour (24-hour clock) 17
Minute 30
Time in minutes =B1*60+B2
Table to find the shift length (works for overnight shifts)
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)
Table to find hours worked and decimal hours
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)
IF (a condition), QUOTIENT (the whole-number part of a division), MOD (the remainder) and ROUND (rounding) are written the same way in Google Sheets as in Excel. Copy the whole table, paste it into cell A1, and replace the values in column B with your own. The answers are the same as in Excel.

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")
Runs with the standard library only. divmod returns the quotient and the remainder of a division at the same time, so dividing minutes by 60 splits them into hours and minutes. Change the start and end times (24-hour clock) and the break at the top, then run the code.

How to write it in LaTeX and other math languages (copy and paste)

Turning a time of day into minutes after midnight
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
Shift length (time from start to end)
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>&#x2212;</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>&#x2212;</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)
Hours worked and decimal hours (subtracting the break and converting for hourly pay)
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>&#x2212;</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
  1. 1
    Enter your numbers
    Type the numbers you want to calculate with into the input fields
  2. 2
    Calculate
    Press the "Calculate" button
  3. 3
    Check the result
    The result appears on the spot. The same page also explains the idea behind the calculation and the formula
  DataChef Features
Easy and Free
Unlimited conversions for free.
No technical knowledge required.
Intuitive and user-friendly operation.
No Registration Required
Available immediately after access.
Can be used without registering personal information.
Safe and Secure
Fully SSL encrypted communication.
Automatic file deletion by clicking "download".
Fast
High-speed site access
and rapid file conversion.
No Watermark
No watermark.
No attribution required.
Commercial Use Available
Free for commercial use.
No need to contact us for commercial use permission.