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.4<br />

Using the NETWORKDAYS function to calculate the number of working days between two dates.<br />

NEW FEATURE<br />

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

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

The following formula uses the WORKDAY function to determine the date that is ten working days from<br />

January 4, 2008. A working day consists of a week day (Monday through Friday).<br />

=WORKDAY(“1/4/2008”,10)<br />

The formula returns a date serial number, which must be formatted as a date. The result is January 18,<br />

2008 (four weekend dates fall between January 4 and January 18).<br />

CAUTION<br />

The preceding formula may return a different result, depending on your regional date setting.<br />

(The hard-coded date may be interpreted as April 1, 2008.) A better formula is<br />

=WORKDAY(DATE(2008,1,4),10)<br />

The second argument for the WORKDAY function can be negative. And, as with the NETWORKDAYS function,<br />

the WORKDAY function accepts an optional third argument (a reference to a range that contains a list of holiday<br />

dates).<br />

Calculating the number of years between two dates<br />

The following formula calculates the number of years between two dates. This formula assumes that cells<br />

A1 and B1 both contain dates:<br />

=YEAR(A1)-YEAR(B1)<br />

This formula uses the YEAR function to extract the year from each date and then subtracts one year from<br />

the other. If cell B1 contains a more recent date than the date in cell A1, the result will be negative.<br />

Note that this function doesn’t calculate full years. For example, if cell A1 contains 12/31/2007 and cell B1<br />

contains 01/01/2008, the formula returns a difference of one year, even though the dates differ by only one<br />

day. See the next section for another way to calculate the number of full years.<br />

235

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

Saved successfully!

Ooh no, something went wrong!