Excel Formula to Calculate Timesheet Hours
In this article
To calculate total hours in an Excel timesheet, subtract the start time from the end time and multiply the result by 24 to convert the time value into a decimal number. For example, if your start time is in cell A2 and your end time is in cell B2, the formula is =(B2-A2)*24. This is necessary because Excel stores time as a fraction of a 24-hour day; without the multiplication, a 4-hour shift would appear as 0.1667 instead of 4.0.
What You'll Need
- Microsoft Excel (any modern version)
- A basic understanding of how to select cells and enter formulas
- Your clock-in and clock-out data for the period you are tracking
- An hourly pay rate if you intend to calculate total earnings
Step-by-Step
- Set Up Your Column Headers: Open a blank Excel workbook. In the first row, create headers to organize your data. In cell A1, type "Date"; in B1, type "Start Time"; in C1, type "Lunch Start"; in D1, type "Lunch End"; in E1, type "End Time"; and in F1, type "Total Hours". This structure ensures you can account for unpaid breaks, which is a standard requirement for most payroll systems.
- Format Your Time Cells: Highlight columns B, C, D, and E. Right-click the selected area, choose "Format Cells", select the "Time" category, and choose a format like "1:30 PM". This tells Excel to treat the data you enter as time values rather than general text or numbers.
- Enter Your Data: Input your dates and times. For example, in cell A2 enter "2023-10-01", in B2 enter "08:00 AM", in C2 enter "12:00 PM", in D2 enter "01:00 PM", and in E2 enter "05:00 PM".
- Create the Hours Calculation Formula: In cell F2, you need to calculate the total elapsed time while subtracting the break. The logic is (End Time minus Start Time) minus (Lunch End minus Lunch Start). Enter the following formula:
=((E2-B2)-(D2-C2))*24. The multiplication by 24 converts the internal Excel time value into a decimal number (e.g., 8.0 instead of 8:00). - Format the Total Hours Cell: After pressing Enter, cell F2 might look like a weird time (like "12:00 AM"). This is because Excel tries to be helpful by applying the time format of the surrounding cells. Right-click cell F2, select "Format Cells", and change the category to "Number" with 2 decimal places. Now, "8.00" will appear correctly.
- Apply the Formula to All Rows: Click the bottom-right corner of cell F2 (the small green square called the fill handle) and drag it down to the bottom of your data set. Excel will automatically adjust the cell references (F3 will use E3, B3, etc.) for each day of the week.
- Calculate the Weekly Total: Below your last entry in column F, use the SUM function to find the total hours for the period. If your data ends at F8, enter
=SUM(F2:F8)in cell F9. - Calculate Total Pay: To find the total earnings, enter your hourly rate in a separate cell (e.g., H2). In cell I2, enter the formula
=F9*H2. Ensure this cell is formatted as "Currency".
Common Mistakes
One of the most frequent errors is forgetting to multiply by 24. Because Excel treats one whole day (24 hours) as the integer 1, an 8-hour workday is mathematically 8/24, or 0.333. If you simply subtract the start time from the end time, your total will be a fraction of a day. When you then multiply that fraction by an hourly wage (e.g., $20), you will get a tiny, incorrect number like $6.66 instead of $160.
Another common mistake is mixing 12-hour and 24-hour time formats inconsistently. If you enter "8:00" without specifying AM or PM, Excel may default to AM. If you enter "5:00" for a 5 PM finish, Excel thinks you finished at 5 AM the same day, resulting in a negative number or a series of hash marks (#######) in the cell. Always use "AM/PM" or use 24-hour military time (e.g., 17:00 for 5 PM) to maintain accuracy.
Users also often forget to subtract the break time. Simply subtracting start from end calculates the total time spent at the workplace, not the actual hours worked. If you have a consistent 30-minute unpaid break every day, you can subtract 0.5 from your final formula, but using specific start and end times for breaks is more accurate for audits.
Tips
To make data entry faster, use the keyboard shortcut Ctrl + Shift + : (colon) to instantly insert the current time into a cell. This is useful if you are updating your timesheet in real-time as you clock in and out.
For those who work shifts that cross over midnight (e.g., starting at 10 PM and ending at 6 AM), the standard subtraction formula will fail because the end time is numerically smaller than the start time. To fix this, use the MOD function: =MOD(E2-B2, 1)*24. The MOD function with a divisor of 1 ensures that the result is always positive, effectively telling Excel to wrap around to the next day.
Use "Conditional Formatting" to highlight overtime. You can set a rule that if the value in the Total Hours column is greater than 8, the cell turns green. This allows you to spot overtime hours at a glance without having to manually check every row.
Troubleshooting
If you see a series of hash marks (#######) in your result cell, it usually means one of two things: the column is too narrow to display the number, or the formula has resulted in a negative time value. First, try widening the column. If that doesn't work, check your time entries. This usually happens when the start time is entered as being later than the end time (e.g., Start 9:00 AM, End 5:00 AM). Ensure your AM/PM designations are correct.
If your total hours are showing as a time (like "4:00") instead of a number (like "4.00"), your cell formatting is wrong. Go to the "Home" tab, look at the "Number" dropdown menu in the ribbon, and change it from "Time" or "Custom" to "Number".
If the SUM function is not adding up correctly, check to see if any of your hours are stored as text. This happens if you typed "8 hours" into a cell instead of just "8". Excel cannot perform math on text. Clear the cell and enter only the numeric value.
Frequently Asked Questions
How do I handle unpaid breaks that vary in length?
The best method is to create two separate columns: "Break Start" and "Break End". Subtract the Break Start from the Break End to find the total break duration, then subtract that result from the total shift duration. This ensures every single minute of unpaid time is accurately removed.
Can I calculate overtime automatically?
Yes. You can use an IF statement. For example, if your standard day is 8 hours, use =IF(F2>8, F2-8, 0) in a new "Overtime" column. This will only show the hours worked beyond the 8-hour threshold.
Why does my total time reset to zero after 24 hours?
By default, Excel's time format resets every 24 hours. To show a cumulative total (e.g., 45 hours for a week), right-click the cell, go to "Format Cells" > "Custom", and enter [h]:mm:ss. The square brackets tell Excel to accumulate hours rather than resetting them.
What is the best way to enter times quickly?
Use the 24-hour clock. Entering "14:00" is faster and less prone to error than typing "2:00 PM". Excel recognizes both, but 24-hour time removes the risk of accidentally swapping AM and PM.
How do I round my hours to the nearest 15 minutes?
Use the MROUND function. To round your total hours to the nearest quarter-hour, use =MROUND(F2, "0:15")*24. This is common in corporate environments where payroll is rounded to the nearest 15-minute increment.