DateSerial function
Returns a Variantof the date subtype for the specified year, month, and day.
DateSerial(year, month, day)
Arguments
Year
A numeric or numeric expression from 100 to 9999.
Month
An arbitrary numeric expression.
Day
An arbitrary numeric expression.
Description
To specify a date, such as December 31, 1991, the range of values for each parameter in theDateSerial function should be acceptable; The value of the day should be between 1 and 31, and the month should be between 1 and 12. However, you can also specify a relative date for each parameter by using a numeric expression that represents the number of years, months, or days before or after a day.
The following sample uses a numeric expression instead of an absolute date. Here, theDateSerial function returns the date of 10 years (1990-10) 2 months (8-2) and one day (1-1) before August 1, 1990: May 31, 1980.
DateSerial(1970, 1, 1)
' Returns January 1, 1970.
DateSerial(1990 - 10, 8 - 2, 1 - 1)
' Returns May 31, 1980.
For The year parameter, if the value range is from 0 to 99, it is interpreted as 1900-1999 years. For year parameters outside of this range, four-digit numbers are used to represent years (for example, 1800).
When the value of any parameter exceeds an acceptable range, it is appropriately rounded to the next larger time unit. For example, if you specify 35 days, the number of days is interpreted as a month plus extra days, depending on the year and month. However, an error occurs if the parameter value exceeds the range of 32,768 to 32,767, or if the date specified by three parameters, whether directly or through an expression, is outside the acceptable date range.