Returns a Variant (Date) for a specified year, month, and day.
v = DateSerial(year, month, day)
NOTE: The DateSerial function can be entered as above but will automatically be converted into DateSerial((year,month,day, )). The parameter after the final comma appears to serve no purpose and a Syntax Error is returned if a value is entered.
v: Variant
year, month, day: iexp
To specify a date, such as December 31, 1991, the range of numbers for each DateSerial argument should be in the accepted range for the unit; that is, 1-31 for days and 1-12 for months. However, you can also specify relative dates for each argument using any numeric expression that represents some number of days, months, or years before or after a certain date.
The following example uses numeric expressions instead of absolute date numbers. Here the DateSerial function returns a date that is the day before the first day (1 - 1), two months before August (8 - 2), 10 years before 1990 (1990 - 10); in other words, May 31, 1980.
DateSerial((1990 - 10, 8 - 2, 1 - 1, ))
For the year argument, values range from 100 to 9999, inclusive.
When any argument exceeds the accepted range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 35 days, it is evaluated as one month and some number of days, depending on where in the year it is applied.
Print DateSerial((1999 - 40, 10 - 12., 30 - 44, )) // prints 16/09/58
The output of the DateSerial function is not affected by Mode Date or Mode Time and separates the date elements with the '/' symbol. To get around this problem and standardise your date format, put the DateSerial function inside Date$() or DateTime$() as below:
Mode Date "."
Print DateSerial((1900, 10, 1, ))
Print Date$(DateSerial((1900, 10, 1,)))
CDate(), Date, Date$, DateAdd(), DateDiff(), DatePart(), DateSerial(), DateTime$(), DateToDmy, DateToDmyHms, DateValue(), Day(), DayNo(), DmyHmsToDate(), DmyToDate(), HmsToTime(), Hour(), IsDate(), Minute(), Month(), Now, Now$(), TimeSerial(), TimeToHms, TimeValue(), Second(), Week(), WeekDay(), Year()
{Created by Sjouke Hamstra; Last updated: 28/09/2014 by James Gaite}