DateSerial()

Syntax: DateSerial(Year as integer, Month as integer, Day as integer)

The DateSerial function creates a Date value from separate month, day, and year values.

Each argument is an integer expression specifying the corresponding date component.  To represent specific dates, month can range from 1 to 12, day from 1 to 31, and year from 100 to 9999. You can also create a value that represents a relative date. For example, a month value of -2 would create a relative date that is two months prior to another date.

Parameters:

Year: Is an integer between 1 through 9999.  If the Year is between 0 through 99 DateSerial will return a year between 1930 and 2029.  If the year is negative it will be subtracted from the current year (based on tests it seems that it is actually subtracted from the year 2000.

Month: Is an integer between 1 through 12.  If you use a negative number it will be subtracted from the year, so if the year is 2011 and the month is -1 it would return with November 2010, -2 would be October 2010 and so on.  If you use a number larger than 12 then it would be added on, so 13 would be January 2012 in this example.

Day: Is an integer between 1 to 31.  A value of 0 would be the last day of the previous month, -1 would be the day before the last day of the previous month and so on.  Also if you use days larger than 31 you will have a date in the next month.

Script: 
Sub Main
	Dim aDate As Date 
	aDate = DateSerial(2012, 2, 12)
	MsgBox aDate '2012/02/12
	
	aDate = DateSerial(10, 3, 31)
	MsgBox aDate '2010/03/31
	
	aDate = DateSerial(2010, -1, 25)
	MsgBox aDate '2009/11/25
	
	aDate = DateSerial(2010, 3, -1)
	MsgBox aDate '2010/2/27
End Sub

IDEAScript Language: