DATESERIAL(year, month, day)

Returns the date given a year, month and day (Date).


yearThe year between 1 and 9999, inclusively (Integer).
monthThe month between 1 and 12 (Integer).
dayThe day between 1 and 31 (Integer).

REMARKS
* This function can accept values outside the normal range.
* For example if you pass in the year 2010 and the month 14, it will return a date in the second month of 2011 (ie it will add 14 months).
* You can 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.
* When an argument exceeds the accepted range, it increments to the next larger unit as appropriate.
* If any argument is outside -32,768 to 32,767, then an error occurs.
* The "year" should be entered as a four-digit year.
* If "year" is between 0 and 29, inclusive, are interpreted as the years 2000-2029.
* If "year" is between 30 and 99 are interpreted as the years 1930-1999.
* If "year" is between 0 and 99, inclusive, are interpreted as the years 1400-1499.
* If "year" < 1, then this number is subtracted from the current year.
* If "month" = 0, then it represents December of the previous year.
* If "month" = 13, then it represents January of the next year.
* If "day" = 35, then it represents one month plus a certain number of day depending on the actual date.
* If "day" = -1, then it represents November of the previous year.
* A practical use of this function is to identify leap years << User Defined Function >>.
* You can use the FORMAT function to return
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.DateSerial
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print DateSerial(1, 1, 1)                 '01/01/2001  
Debug.Print DateSerial(2008,8,1) '01/08/2008
Debug.Print DateSerial(2008 - 8,12 - 2,5) '05/10/2000
Debug.Print DateSerial(2008,12,2) '02/12/2008
Debug.Print DateSerial(2008,12 + 2,2 + 30) '04/03/2009
Debug.Print DateSerial(1900,02,29) = 1/3/1900 '29 days added

Dim lserial As Long
lserial = DateSerial(2012,7,2)
Debug.Print lserial

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top