contents.gifindex.gifprev1.gifnext1.gif

DateSerial

Purpose

Returns the date for a specific year, month, and day.

Arguments

DateSerial(

year
A number between 0 - 9999, inclusive, or a numeric expression.
, month
A number between 1 - 12, inclusive, or a numeric expression
, day
A number between 1 - 31, inclusive, or a numeric expression
)

Notes

To express a specific date, such as December 31, 1994, the range of numbers for each DateSerial argument should conform to the accepted range of values for the unit. These values are 1 through 31 for days and 1 through 12 for months. You can also specify relative dates for each argument by using a numeric expression representing the number of days, months, or years before or after a certain date.

For the argument year, values between 0 and 99, inclusive, are interpreted as the years 1900-1999. For all other year arguments, use the complete four-digit year (for example, 1800).

The DateSerial function returns a Variant of VarType 7 (Date) containing a date that is stored internally as a double-precision number. This number represents a date from January 1, 100 through December 31, 9999, where January 1, 1900 is 2. Negative numbers represent dates prior to December 30, 1899.

If the date specified by the three arguments, either directly or by expression, falls outside the acceptable range of dates, an error occurs.

Example

The following example uses expressions instead of absolute date numbers. The DateSerial function returns a date that is the day before the first day (1 - 1) of two months before August (8 - 2) of 10 years before 1990 (1990 - 10)in other words, May 31, 1980:

= DateSerial(1990 - 10, 8 - 2, 1 - 1)