Page 278 - Excel 2007 Bible
P. 278

18_044039 ch13.qxp  11/21/06  11:05 AM  Page 235
                                                                                            Working with Dates and Times
                                       FIGURE 13.4
                                     Using the NETWORKDAYS function to calculate the number of working days between two dates.
                                                       In versions prior to Excel 2007, the WORKDAY function was available only when the Analysis  13
                                      NEW FEATURE      ToolPak add-in was installed. The function is now part of Excel 2007.
                                      NEW FEATURE
                                             The following formula uses the WORKDAY function to determine the date that is ten working days from
                                            January 4, 2008. A working day consists of a week day (Monday through Friday).
                                                 =WORKDAY(“1/4/2008”,10)
                                             The formula returns a date serial number, which must be formatted as a date. The result is January 18,
                                             2008 (four weekend dates fall between January 4 and January 18).

                                       CAUTION         The preceding formula may return a different result, depending on your regional date setting.
                                       CAUTION
                                                       (The hard-coded date may be interpreted as April 1, 2008.) A better formula is
                                               =WORKDAY(DATE(2008,1,4),10)
                                             The second argument for the WORKDAY function can be negative. And, as with the NETWORKDAYS function,
                                            the WORKDAY function accepts an optional third argument (a reference to a range that contains a list of holi-
                                             day dates).

                                             Calculating the number of years between two dates
                                             The following formula calculates the number of years between two dates. This formula assumes that cells
                                             A1 and B1 both contain dates:

                                                 =YEAR(A1)-YEAR(B1)
                                             This formula uses the YEAR function to extract the year from each date and then subtracts one year from
                                            the other. If cell B1 contains a more recent date than the date in cell A1, the result will be negative.
                                            Note that this function doesn’t calculate full years. For example, if cell A1 contains 12/31/2007 and cell B1
                                             contains 01/01/2008, the formula returns a difference of one year, even though the dates differ by only one
                                             day. See the next section for another way to calculate the number of full years.



                                                                                                                      235
   273   274   275   276   277   278   279   280   281   282   283