How to add or subtract a date in the DateAdd function in ASP

Source: Internet
Author: User

How to Use the DateAdd function in ASP

Note that the vbs and SQL statements are slightly different. The following post provides vbs help.

SQL searchable SQL built-in help documentation
String expression, indicating the time interval to be added. For values, see "Settings.
Returns the date of the specified interval.
DateAdd (interval, number, date)

Parameters
Interval
Required.
Number
Required. Numeric expression, indicating the number of time intervals to be added. A numeric expression can be a positive number (to get the future date) or a negative number (to get the past date ).
Date
Required. Variant or the text that represents the date to add interval.

Set
The interval parameter can have the following values:
Table

Description
The DateAdd function can be used to add or subtract a specified time interval from a date. For example, you can use DateAdd to start from the day 30 days later or 45 minutes later than the current day. To add a time interval in the unit of "day" To date, you can use "day of the year" ("y"), "day" ("d ") or "the number of days in a week" ("w ").
The DateAdd function does not return an invalid date. In the following example, we will add a month to April January 31:
NewDate = DateAdd ("m", 1, "31-Jan-95") in this example, DateAdd returns February 28, instead of February 31, 95. If date is January 31, the return value is February 29, because 1996 is a leap year.
If the calculation date is before January 1, 100 AD, an error occurs.
If the number is not a Long value, the first rounding is the nearest integer.
Datediff is similar

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.