18.11.2014 Views

Microsoft Office

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Part II<br />

Working with Formulas and Functions<br />

Excel automatically formats this formula cell as a date rather than as a numeric value. Therefore, you will<br />

need to change the number format so that the result is displayed as a nondate. If cell B1 contains a more<br />

recent date than the date in cell A1, the result will be negative.<br />

NOTE<br />

If this formula does not display the correct value, make sure that A1 and B1 both contain<br />

actual dates — not text that looks like a date.<br />

Sometimes, calculating the difference between two days is more difficult. To demonstrate, consider the common<br />

fence-post analogy. If somebody asks you how many units make up a fence, you can respond with<br />

either of two answers: the number of fence posts or the number of gaps between the fence posts. The number<br />

of fence posts is always one more than the number of gaps between the posts.<br />

To bring this analogy into the realm of dates, suppose that you start a sales promotion on February 1 and<br />

end the promotion on February 9. How many days was the promotion in effect? Subtracting February 1<br />

from February 9 produces an answer of eight days. Actually, the promotion lasted nine days. In this case,<br />

the correct answer involves counting the fence posts, not the gaps. The formula to calculate the length of<br />

the promotion (assuming that you have appropriately named cells) appears like this:<br />

=EndDay-StartDay+1<br />

Calculating the number of work days between two dates<br />

When calculating the difference between two dates, you may want to exclude weekends and holidays. For<br />

example, you may need to know how many business days fall in the month of November. This calculation<br />

should exclude Saturdays, Sundays, and holidays. The NETWORKDAYS function can help out.<br />

NEW FEATURE<br />

In versions prior to Excel 2007, the NETWORKDAYS function was available only when the<br />

Analysis ToolPak add-in was installed. The function is now part of Excel 2007.<br />

The NETWORKDAYS function calculates the difference between two dates, excluding weekend days<br />

(Saturdays and Sundays). As an option, you can specify a range of cells that contain the dates of holidays,<br />

which are also excluded. Excel has absolutely no way of determining which days are holidays, so you must<br />

provide this information in a range.<br />

Figure 13.4 shows a worksheet that calculates the work days between two dates. The range A2:A11 contains<br />

a list of holiday dates. The two formulas in column C calculate the work days between the dates in<br />

column A and column B. For example, the formula in cell C15 is<br />

=NETWORKDAYS(A15,B15,A2:A11)<br />

This formula returns 4, which means that the seven-day period beginning with January 1 contains four<br />

work days. In other words, the calculation excludes one holiday, one Saturday, and one Sunday. The formula<br />

in cell C16 calculates the total number of work days in the year.<br />

ON the CD-ROM<br />

This workbook is available on the companion CD-ROM. The file is named work days.xlsx.<br />

Offsetting a date using only work days<br />

The WORKDAY function is the opposite of the NETWORKDAYS function. For example, if you start a project<br />

on January 4, and the project requires ten working days to complete, the WORKDAY function can calculate<br />

the date you will finish the project.<br />

234

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

Saved successfully!

Ooh no, something went wrong!