Sunday, 18 September 2011

Displaying any date

Displaying any date

As explained earlier in this chapter, you can easily enter a date into a cell by simply typing it,
using any of the date formats that Excel recognizes. You can also create a date by using the
DATE function, which takes three arguments: the year, the month, and the day. The following for-
mula, for example, returns a date comprising the year in cell A1, the month in cell B1, and the day
in cell C1:

  =DATE(A1,B1,C1)

              The DATE function accepts invalid arguments and adjusts the result accordingly. For
              example, this next formula uses 13 as the month argument, and returns January 1, 2010.
              The month argument is automatically translated as month 1 of the following year.

                  =DATE(2009,13,1)

Often, you’ll use the DATE function with other functions as arguments. For example, the formula
that follows uses the YEAR and TODAY functions to return the date for Independence Day (July
4th) of the current year:

  =DATE(YEAR(TODAY()),7,4)

The DATEVALUE function converts a text string that looks like a date into a date serial number.
The following formula returns 40412, the date serial number for August 22, 2010:

  =DATEVALUE(“8/22/2010”)

No comments:

Post a Comment