Sqlserver get date function year month day format

Source: Internet
Author: User
Method 1 Code as follows SELECTconvert (char (6), getdate (), 112) method 2 Code as follows select * from table name whereConvert (varchar (100), Date Field, 23) use the Convert () function: selectconvert (char (10), GetDate (), 120) asDate * 3rd parameters are used to set the date type

Method 1 Code as follows SELECT convert (char (6), getdate (), 112) method 2 Code as follows select * from table name where Convert (varchar (100), Date Field, 23) = '2017-12-15' use the Convert () function: select convert (char (10), GetDate (), 2013) as Date * 120 parameters are used to set the Date type

Method 1

The Code is as follows:

SELECT convert (char (6), getdate (), 112)

Method 2

The Code is as follows:


Select * from table name where Convert (varchar (100), Date Field, 23) = '2017-12-15'

Use the Convert () function:

Select convert (char (10), GetDate (), 120) as Date

* The 3rd parameters are used to set the display style of the date data. The following describes several style parameters:

100mm dd yyyy

101/dd/yyyy

102 yyyy. mm. dd

103 dd/mm/yyyy

106 dd mm yyyy

108 hh: mi: ss (time)

111 yyyy/mm/dd

112 yyyymmdd

120 yyyy-mm-dd

,

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.