The date and time functions enable you to convert dates and times to serial numbers and perform operations on those numbers. This capability is useful for such things as accounts receivable aging, project scheduling, time-management applications, and much more. This chapter introduces you to Excel's date and time functions and puts them through their paces with many practical examples.
Returning a Date
If you need a date for expression operand for a function argument, you can always enter it by hand if you have a specific date in mind. Much of the time, however, you need more flexibility, such as always entering the current date or building a date from day, month, and year components. Excel offers three functions that can help: TODAY( ), DATE( ), and DATE VALUE( ).
TODAY ( ): Returning the Current Date
When you need to use the current date in a formula, function, or expression, use the TODAY ( ) function, which doesn't take any arguments:
Syntax: TODAY ( )
This function returns the serial number (or current date) of the current date. For example, if today date is December 31, 2007, the TODAY ( ) function returns the following serial number:
39447.0
Note that TODAY ( ) is a dynamic function that doesn't always return the same value. Each time you edit the formula, enter another formula, recalculate the worksheet, or reopen the workbook, TODAY ( ) updates its value to return the current system date.
DATE ( ): Returning Any Date
A date consists of three components: the year, month, and day. It often happens that a worksheet generates one or more of these components, and you need some way of building a proper date out of them. You can do that by using Excel's DATE ( ) function:
Syntax: DATE (year, month, day)
Year: The year component of the date (a number between 1900 and 9999)
Month: month component of the date
Day: The day component of the date
Type: =DATE(2005, 8, 14) in any cell
Returns: 14-8-2005
DATEVALUE ( ) Converting a String to a Date
If you have a date value in string form, you can convert it to a date serial number by using the DATE VALUE ( ) function:
Syntax: DATEVALUE("date_text")
Date‑Text: The string containing the date
Example: The following expression returns the date serial number for the string August 23, 2007, Type
this formula =DATEVALUE("august 23, 2007")
Returns: 39317
Returning Parts of a Date
The three components of a date - year, month, and day - can also be extracted individually from a given date. This might not seem all that interested at first, but actually many useful techniques arise out of working with a date's component pads. A date's components are extracted using Excel's YEAR (), MONTH (), and DAY
( ) functions.