VBS tutorial: function – DateAdd function


DateAdd function

Returns the date to which the specified time interval has been added.

DateAdd(interval, number, date)



Required. A string expression representing the time interval to add. For values, see the settings section.


Required. A numeric expression representing the number of time intervals to add. Numeric expressions can be positive (get future dates) or negative (get past dates).


Required.VariantOr to addintervalThe text representing the date.

set up

intervalParameters can have the following values:

set up describe
yyyy year
q quarter
m month
y Days of the year
d day
w Days of the week
ww week
h hour
n minute
s second


availableDateAddFunction adds or subtracts a specified time interval from a date. For example, you can useDateAddA date 30 days from that day or 45 minutes from now. TodateTo add a time interval in days, you can use days of the year (“Y”), days of the week (“d”), or days of the week (“W”).

DateAddThe function does not return an invalid date. The following example adds one month to January 31, 1995:

NewDate = DateAdd("m", 1, "31-Jan-95")

In this example,DateAddReturn to February 28, 1995 instead of February 31, 1995. IfdateIf it is January 31, 1996, it returns February 29, 1996, because 1996 is a leap year.

If the calculated date is before A.D. 100, an error will occur.

IfnumbernoLongType value, rounded to the nearest integer before calculation.