VBS Tutorial: function-DateAdd Function

Source: Internet
Author: User

DateAdd Function

Returns the date of the specified interval.

DateAdd(interval, number, date)

Parameters

Interval

Required. String expression, indicating the time interval to be added. For values, see the "Settings" section.

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.VariantOr you want to addInterval.

Set

IntervalParameters can have the following values:

Set Description
Yyyy Year
Q Quarter
M Month
Y Number of days per year
D Day
W Number of days in a week
Ww Week
H Hours
N Minutes
S Seconds

Description

AvailableDateAddThe function adds or removes the specified time interval from the date. For example, you can useDateAddThe date 30 days later than the current day or 45 minutes later than the current day. To forwardDateAdd the time interval in the unit of "day". You can use "day of the year" ("y") and "day" ("d ") or "number of days in a week" ("w ").

DateAddThe 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,DateAddReturn February 28, instead of February 31. IfDateIf the value 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.

IfNumberNoLongType value, the first rounding is the nearest integer.

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.