How to Use the dateadd Function

Source: Internet
Author: User
DateAdd
Returns the DateAdd function.

Returns the Variant (Date) that contains a Date. This Date is added with a time interval.

Syntax

DateAdd (interval, number, date)

The DateAdd function syntax includes the following naming parameters:

Partial description

Interval is required. String expression, which is the time interval to be added.

Number is required. A numeric expression is the number of time intervals to be added. The value can be a positive number (to get the future date) or a negative number (to get the past date ).

Date is required. Variant (Date) or text that represents the Date, which is added with the time interval.

Set

The interval parameter has the following settings:

Set description

Yyyy

Q quarter

M month

Y number of days in a year

D

Number of days per week

Ww week

H hour

N minutes

S seconds

Description

You can use the DateAdd function to add or subtract the specified time interval from the date. For example, you can use DateAdd to calculate the date of thirty days from the past day, or 45 minutes from now.

To add "day" To date, you can use "day of the year" ("y"), "day" ("d ") or "number of days in a week" ("w ").

The DateAdd function does not return a valid date. Add April 1 to the previous month in the following instances:

DateAdd (m, 1, 31-Jan-95)

In the preceding example, DateAdd returns January 1, February 28, 1995 instead of January 1, February 31, 1995. If date is January 1, January 31, 1996, because January 1, 1996 is a leap year, the return value is January 1, February 29, 1996.

If the calculated date is later than 100 (the year minus the year beyond the year in the date), an error occurs.

If number is not a Long value, the nearest integer is used for calculation.

Note that the format of the DateAdd return value is determined by the Control Panel setting, rather than by the format passed to the date parameter.

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.