18.11.2014 Views

Microsoft Office

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Dates and Times 13<br />

FIGURE 13.8<br />

An employee timesheet workbook.<br />

The first part of this formula subtracts the time in column D from the time in column E to get the total<br />

hours worked before lunch. The second part subtracts the time in column F from the time in column G to<br />

get the total hours worked after lunch. I use IF functions to accommodate graveyard shift cases that span<br />

midnight — for example, an employee may start work at 10:00 PM and begin lunch at 2:00 AM. Without<br />

the IF function, the formula returns a negative result.<br />

The following formula in cell H17 calculates the weekly total by summing the daily totals in column H:<br />

=SUM(H8:H14)<br />

This worksheet assumes that hours in excess of 40 hours in a week are considered overtime hours. The<br />

worksheet contains a cell named Overtime, in cell C23. This cell contains 40:00. If your standard workweek<br />

consists of something other than 40 hours, you can change this formula.<br />

The following formula (in cell H18) calculates regular (nonovertime) hours. This formula returns the<br />

smaller of two values: the total hours or the overtime hours.<br />

=MIN(E17,Overtime)<br />

The final formula, in cell H19, simply subtracts the regular hours from the total hours to yield the overtime<br />

hours.<br />

=E17-E18<br />

The times in H17:H19 may display time values that exceed 24 hours, so these cells use a custom number<br />

format:<br />

[h]:mm<br />

245

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!