11.08.2013 Views

Excel's Formula - sisman

Excel's Formula - sisman

Excel's Formula - sisman

SHOW MORE
SHOW LESS

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

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

Chapter 6: Working with Dates and Times 173<br />

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

H:<br />

=SUM(H8:H14)<br />

This worksheet assumes that hours that exceed 40 hours in a week are considered overtime<br />

hours. The worksheet contains a cell named Overtime (cell C23) that contains 40:00. If your standard<br />

workweek consists of something other than 40 hours, you can change the Overtime cell.<br />

The following formula (in cell E18) calculates regular (non-overtime) hours. This formula returns<br />

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

=MIN(E17,Overtime)<br />

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

overtime hours:<br />

=E17-E18<br />

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

number format:<br />

[h]:mm<br />

The workbook shown in Figure 6-7, time sheet.xlsm, also appears on the companion<br />

CD-ROM.<br />

Calculating the difference between two times<br />

Because times are represented as serial numbers, you can subtract the earlier time from the later<br />

time to get the difference. For example, if cell A2 contains 5:30:00 and cell B2 contains 14:00:00,<br />

the following formula returns 08:30:00 (a difference of eight hours and 30 minutes):<br />

=B2-A2<br />

If the subtraction results in a negative value, however, it becomes an invalid time; Excel displays<br />

a series of hash marks (#######) because a time without a date has a date serial number of 0. A<br />

negative time results in a negative serial number, which cannot be displayed — although you can<br />

still use the calculated value in other formulas.

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

Saved successfully!

Ooh no, something went wrong!