VBScript DateAdd Function

Definition and Usage

The DateAdd function can return a date with the specified time interval added.

Syntax

DateAdd(interval,number,date)
Parameter Description
interval

Required. The interval to be added.

The following values can be used:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - The day of the year
  • d - Day
  • w - The day of the week
  • ww - Week
  • h - Hour
  • n - Minute
  • s - Second
number Required. The number of intervals to be added. You can use a positive value for future dates and a negative value for past dates.
date Required. Represents the variable or text of the date to be added.

Example

Example 1

Add one month to January 31, 2000:

document.write(DateAdd("m",1,"31-Jan-00"))

Output:

2/29/2000

Example 1

Add one month to January 31, 2001:

document.write(DateAdd("m",1,"31-Jan-01"))

Output:

2/28/2001

Example 1

Subtract one month from January 31, 2001:

document.write(DateAdd("m",-1,"31-Jan-01"))

Output:

12/31/2000

Try It Yourself

DateAdd
How to use the DateAdd function to add a month to a date.
DateAdd
How to use the DateAdd function to subtract a month from a date.