SQL adds a fixed time for the time field

Source: Internet
Author: User
The createtime field in the usertable in the database is added for ten days.
Use Database
Update [usertable] Set createtime = dateadd (day, 10, createtime)

Dateadd Introduction

Returns the newDatetimeValue.

Syntax Dateadd( Datepart, Number, Date) Parameters

Datepart

Is a parameter that specifies which part of the date should be returned to the new value. The following table lists the dates and abbreviations recognized by Microsoft SQL Server.

Date Abbreviations
Year YY, yyyy
Quarter QQ, Q
Month Mm, m
Dayofyear Dy, y
Day DD, d
Week Wk, WW
Hour HH
Minute Mi, n
Second SS, S
Millisecond MS

Number

Is used to addDatepart. If you specify a value that is not an integer, the fractional part of the value is discarded. For exampleDatepartSpecifyDay, IsNumberSpecify1.75, ThenDateIt will increase by 1.

Date

YesDatetimeOrSmalldatetimeValue or date format string expression.

If you only specify the last two digits of the year, the number of the last two digits smaller than or equal to the value of the "two-digit year deadline" configuration option is in the same century as the end year. The last two-digit number greater than the value of this option is in the century before the end of the century. For example, ifTwo digit year cutoffIs 2049 (default), then 49 is interpreted as 2049,2050 is interpreted as 1950. To avoid blurring, use a four-digit year.

Return type

datetime, is returned. However, if the date parameter is smalldatetime, smalldatetime is returned.

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.