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:
|
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