This article will introduce how to add or subtract dates in the DateAdd function in ASP. Friends who need to know more can refer to the usage of the DateAdd function in ASP.
2006/09/22 12:29
Note that the writing methods in vbs and sql are slightly different. The following post is for vbs help.
SQL's searchable SQL comes with help documentation
A string expression representing the time interval to add. See the Settings section for numerical values.
Returns the date to which the specified time interval has been added.
DateAdd(interval, number, date)
parameter
interval
Required.
number
Required. Numeric expression indicating the number of time intervals to be added. Numeric expressions can be positive (getting a date in the future) or negative (getting a date in the past).
date
Required. Variant or text representing the date to which interval is to be added.
set up
The interval parameter can have the following values:
table
illustrate
You can use the DateAdd function to add or subtract a specified time interval from a date. For example, you can use DateAdd to calculate a date 30 days from the current day or a time 45 minutes from now. To add a time interval in days to date, you can use days of the year (y), days (d), or days of the week (w).
The DateAdd function does not return invalid dates. The following example adds one month to January 31, 1995:
NewDate = DateAdd(m, 1, 31-Jan-95) In this example, DateAdd returns February 28, 1995, not February 31, 1995. If the date is January 31, 1996, February 29, 1996 is returned because 1996 is a leap year.
If the calculated date is before AD 100, an error will occur.
If number is not a Long value, it is rounded to the nearest integer before calculation.
datediff uses something like