Page 288 - Excel 2007 Bible
P. 288
18_044039 ch13.qxp 11/21/06 11:05 AM Page 245
Working with Dates and Times
FIGURE 13.8
An employee timesheet workbook.
The first part of this formula subtracts the time in column D from the time in column E to get the total 13
hours worked before lunch. The second part subtracts the time in column F from the time in column G to
get the total hours worked after lunch. I use IF functions to accommodate graveyard shift cases that span
midnight — for example, an employee may start work at 10:00 PM and begin lunch at 2:00 AM. Without
the IF function, the formula returns a negative result.
The following formula in cell H17 calculates the weekly total by summing the daily totals in column H:
=SUM(H8:H14)
This worksheet assumes that hours in excess of 40 hours in a week are considered overtime hours. The
worksheet contains a cell named Overtime, in cell C23. This cell contains 40:00. If your standard workweek
consists of something other than 40 hours, you can change this formula.
The following formula (in cell H18) calculates regular (nonovertime) hours. This formula returns the
smaller of two values: the total hours or the overtime hours.
=MIN(E17,Overtime)
The final formula, in cell H19, simply subtracts the regular hours from the total hours to yield the overtime
hours.
=E17-E18
The times in H17:H19 may display time values that exceed 24 hours, so these cells use a custom number
format:
[h]:mm
245