SQL Server conver Method

Source: Internet
Author: User

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.

Syntax:

Convert (data_type (length), date_to_be_converted, style)

Date_type (length) specifies the target data type (with optional length ). Data_to_be_converted contains the value to be converted. Style specifies the output format of the date/time.

Values of the available styles:

Styleid style format

100 or 0 mon dd yyyy hh: miam (or pm)

101/DD/yy

102 yy. Mm. dd

103 dd/mm/yy

104 dd. mm. yy

105 DD-mm-yy

106 dd mon YY

107 mon DD, YY

108 hh: mm: SS

109 or 9 Mon dd yyyy hh: MI: SS: mmmam (or pm)

110-dd-yy

111 YY/MM/dd

112 yymmdd

113 or 13 dd mon yyyy hh: mm: SS: Mmm (24 h)

114 hh: MI: SS: Mmm (24 h)

120 yyyy-mm-dd hh: MI: SS (24 h)

121 yyyy-mm-dd hh: MI: Ss. Mmm (24 h)

126 yyyy-mm-ddthh: mm: Ss. Mmm

130 dd mon yyyy hh: MI: SS: mmmam

131 dd/mm/yy hh: MI: SS: mmmam

------------------------------

Convert (varchar (19), getdate ())

Convert (varchar (10), getdate (), 110)

Convert (varchar (11), getdate (), 106)

Convert (varchar (24), getdate (), 113)

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.