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