T-SQL is counted by year, month, day according to date time

Source: Internet
Author: User

See Statistical results:

Here is the CONVERT function, and here we have to say the CONVERT function

The CONVERT () function is a general function that converts a date to a new data type.

The CONVERT () function can display date/time data in different formats.

Grammar
CONVERT (data_type (length),data_to_be_converted,style)

Data_type (length) The data type to be converted, you can specify the length of the data type, in this case by year, the specified conversion to a string type, length 4,
The field to convert, in this case the Createtime
style Specifies the date/time output format . Optional Fields
Format refer to the table below:

Detailed reference:
Http://www.w3school.com.cn/sql/func_convert.asp

T-SQL is counted by year, month, day according to date time

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.