SQL Server Common functions

Source: Internet
Author: User
Tags getdate

1. DATEADD returns a new datetime value based on adding a period of time to the specified date. The syntax DateAdd (datepart, number, date) parameter datepart is a parameter that specifies which part of the date should be returned to the new value. The following table lists the Microsoft? SQL Server?identifies the date part and abbreviation. Date part abbreviation year yy, Yyyyquarter QQ, qmonth mm, mdayofyear dy, yday dd, Dweek wk, W Whour hhminute mi, nsecond SS, Smillisecond Msnumber is used to increase the value of datepart. If you specify a value that is not an integer, the fractional part of this value is discarded. For example, if you specify day for datepart, specify1.75, then date will increase1. Date is an expression that returns a DateTime or smalldatetime value or a date format string. For more information on the specified date, see DateTime and smalldatetime. If you specify only the last two digits of the year, it is less than or equal to"Two-digit year cutoff period"The number of the last two digits of the value of the configuration option is in the same century as the cutoff year. The number of the last two digits of the value of the option is greater than the century of the first century in which the cutoff year was located. For example, if the digit year cutoff is2049(default), the thebe interpreted as2049,2050be interpreted as1950. To avoid blurring, use a four-digit year. The return type returns a DateTime, but returns smalldatetime if the date parameter is smalldatetime. GetDate by datetime value for Microsoft? SQL Server?the standard internal format returns the current system date and time. Syntax getdate () returns a type datetime comment Date function that can be used in the select list of a SELECT statement or in the WHERE clause of a query. When you design a report, the GETDATE function can be used to print the current date and time each time the report is generated. GETDATE is also useful for tracking activities, such as recording when a transaction occurs on an account. Month returns an integer representing the month of the specified date. Syntax month (date)

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.