DATESERIAL(year, month, day)

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

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

* 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.
* To be sure the function returns the proper value, use a four-digit year.
* When an argument exceeds the accepted range, it increments to the next larger unit as appropriate. For example if you specify 35 days it is equivalent to one month plus a certain number of day depending on the actual date.
* If any argument is outside -32,768 to 32,767, then an error occurs.
* The returned date part is in the time period units of the current Visual Basic calendar.
* Under Windows 98 or Windows 2000, two digit years for the year argument are interpreted based on user defined machine settings. The default settings are that values between 0 and 29, inclusive, are interpreted as the years 2000-2029. The default values between 30 and 99 are interpreted as the years 1930-1999. For all other year arguments, use a four-digit year (for example, 1800).
* For the argument year, values between 0 and 99, inclusive, are interpreted as the years 1400-1499. For all other year values, use the complete four-digit year (for example, 1520).
* A practical use of this function is to identify leap years << User Defined Function >>.
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.DateSerial
* For the Microsoft documentation refer to

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)

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