فونکشن DateAdd در VBScript

تعریف و استفاده

DateAdd فونکشن می‌تواند تاریخ جدیدی که زمان مشخص شده‌ای را به آن اضافه کرده است، بازگرداند.

语法

DateAdd(interval,number,date)
参数 Description
interval

Required. The time interval to be added.

The following values can be used:

  • yyyy - Year
  • q - Quarter
  • m - Month
  • y - Day of the year
  • d - Day
  • w - Day of the week
  • ww - Week
  • h - Hour
  • n - Minute
  • s - Second
number Required. The number of time intervals to be added. 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 representing the time interval to be added.

Instance

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

TIY

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.