SQL built-in functions

Source: Internet
Author: User

SQL Server has many built-in functions. Below I will summarize my frequently used functions:

1. getdate () obtains the current system time.

2. datediff (unit of difference, previous time, and later time) Comparison Time Difference

Example: Select datediff (day, '2017-03-14 ', getdate ())

Result 1

Note: The result is a negative value (after time-before time!

3. Convert () data type conversion

Let's talk about common date conversion for specific string formats

Convert (varchar, time, style number)

For example, the time is 23:29:37. 703 (obtained using the preceding getdate)

Style number: 8 in the format of 23:30:37

23 format:

20 format: 23:31:09

Note: you do not need to specify the length of varchar.

4. sum (), max (), min (), AVG (), count ()

Note: These functions ignore null values.

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.