Hours Worked Calculator
Enter your start time, end time, and any break duration to calculate total working hours.
How to Calculate Hours Worked in Excel: A Comprehensive Guide
Accurately tracking hours worked is crucial for payroll, project management, and understanding productivity. While manual calculations can be prone to errors, Microsoft Excel offers powerful tools to automate this process. This guide will walk you through the essential formulas and techniques to calculate hours worked efficiently in Excel, including handling breaks and overnight shifts.
Understanding Time in Excel
Before diving into formulas, it's important to understand how Excel handles time. Excel stores time as a fraction of a 24-hour day. For example, 6:00 AM is 0.25, 12:00 PM is 0.5, and 6:00 PM is 0.75. When you enter a time like "9:00 AM", Excel converts it to its decimal equivalent, but displays it in a user-friendly time format. This fractional representation is key to performing calculations.
Basic Calculation: End Time Minus Start Time
The simplest scenario involves calculating hours worked within the same day without any breaks. You'll need two columns: one for "Start Time" and one for "End Time".
Step-by-Step:
- Enter Times: In cell A2, enter "9:00 AM" (or "9:00"). In cell B2, enter "5:00 PM" (or "17:00").
- Apply Formula: In cell C2, enter the formula:
=B2-A2 - Format Result: The result might initially appear as a decimal number (e.g., 0.3333). To display it as hours and minutes, right-click on cell C2, select "Format Cells…", go to the "Number" tab, choose "Custom", and enter the type
[h]:mm. The square brackets around 'h' ensure that if the total hours exceed 24, they are displayed correctly (e.g., 25:00 instead of 1:00).
Example: If A2 is 9:00 AM and B2 is 5:00 PM, the formula =B2-A2 will result in 8:00 (8 hours).
Calculating Hours with Breaks
Most workdays include breaks. To account for these, you'll need an additional column for "Break Duration". It's often easiest to enter break duration in minutes or as a time value.
Method 1: Break Duration in Minutes
If you enter your break duration in minutes (e.g., 30 for 30 minutes), you need to convert these minutes into Excel's time format (fraction of a day) before subtracting.
- Enter Times: A2: "9:00 AM", B2: "5:00 PM".
- Enter Break: C2: "30" (for 30 minutes).
- Apply Formula: In cell D2, enter the formula:
=B2-A2-(C2/1440) - Format Result: Format cell D2 as
[h]:mm.
Explanation: There are 1440 minutes in a day (24 hours * 60 minutes). Dividing the break minutes by 1440 converts them into Excel's daily fraction format, allowing for correct subtraction from the total shift time.
Example: If A2 is 9:00 AM, B2 is 5:00 PM, and C2 is 30, the formula =B2-A2-(C2/1440) will result in 7:30 (7 hours and 30 minutes).
Method 2: Break Duration as Time
If you enter your break duration directly as a time (e.g., "0:30" for 30 minutes), the formula is simpler.
- Enter Times: A2: "9:00 AM", B2: "5:00 PM".
- Enter Break: C2: "0:30" (for 30 minutes).
- Apply Formula: In cell D2, enter the formula:
=B2-A2-C2 - Format Result: Format cell D2 as
[h]:mm.
Example: If A2 is 9:00 AM, B2 is 5:00 PM, and C2 is 0:30, the formula =B2-A2-C2 will result in 7:30.
Handling Overnight Shifts
When a shift crosses midnight (e.g., starting at 10:00 PM and ending at 6:00 AM the next day), a simple subtraction `End Time – Start Time` will yield a negative result or an error because Excel assumes both times are on the same day. To correct this, you need to add 1 (representing one full day) to the end time if it's earlier than the start time.
Formula for Overnight Shifts (with optional break):
- Enter Times: A2: "10:00 PM", B2: "6:00 AM".
- Enter Break: C2: "60" (for 60 minutes).
- Apply Formula: In cell D2, enter the formula:
=IF(B2<A2, (B2+1)-A2, B2-A2) - (C2/1440) - Format Result: Format cell D2 as
[h]:mm.
Explanation:
IF(B2<A2, (B2+1)-A2, B2-A2): This part checks if the end time (B2) is earlier than the start time (A2). If it is, it means the shift crossed midnight, so it adds 1 (one day) to B2 before subtracting A2. Otherwise, it performs a simple subtraction.- (C2/1440): This subtracts the break duration, assuming it's in minutes, similar to the previous method.
Example: If A2 is 10:00 PM, B2 is 6:00 AM, and C2 is 60, the formula will result in 7:00 (7 hours).
Converting to Decimal Hours
For payroll or project billing, you often need total hours in a decimal format (e.g., 7.5 hours instead of 7:30). Since Excel stores time as a fraction of a day, you simply multiply the time result by 24 (the number of hours in a day).
- Calculate Total Time: Use one of the formulas above to get the total hours worked (e.g., in cell D2, resulting in 7:30).
- Convert to Decimal: In cell E2, enter the formula:
=D2*24 - Format Result: Format cell E2 as "General" or "Number" with two decimal places.
Example: If D2 contains 7:30, the formula =D2*24 will result in 7.5.
Using the Hours Worked Calculator
Our online calculator above provides a quick way to determine total hours worked, including breaks and handling overnight shifts, without needing to set up Excel formulas. Simply input your start time, end time, and break duration in minutes, and it will instantly provide both the hours and minutes format and the decimal hours.
Conclusion
Mastering time calculations in Excel can save significant time and reduce errors in your timekeeping. By understanding how Excel handles time and applying the appropriate formulas for breaks and overnight shifts, you can create robust and accurate timesheets. Whether you use Excel or our convenient online calculator, accurate time tracking is a cornerstone of efficient operations.