SQL Server dateadd function add Date and Time

Source: Internet
Author: User

Address: http://www.isstudy.com/sqlser/2717.html

The dateadd function is used to return a new datetime value based on a specified date.
Syntax:
Dateadd (datepart, number, date)
Parameter description:
Datepart: Specifies the part of the date to which the new value is returned.
The date and abbreviation recognized by sqserver are shown in table 1.

Table 1 Comparison of date and abbreviation
Number: used to increase the value of datepart.
Note: If you specify a value that is not an integer, the fractional part of the value will be discarded.
Date: returns the datetime, smalldatetime, or date format string expression.
Example:
Use the dateadd function to add the specified date to 10 days.ProgramRun result 1.

Figure 1 Add a specified date to 10 days using the dateadd Function
The SQL statement is as follows:
Use Sales Management System
Select time, dateadd (day, 10, time) as "result" from operator information table

 

 

 

Related Article

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.