sql2008-characters to numbers cast and convert

Source: Internet
Author: User

Grammar
Using cast:
CAST (expression as data_type)


Using convert:
CONVERT (data_type[(length)],expression,[style])
Cases:
CONVERT (VARCHAR), GETDATE (), 120)
120 or Yyyy-mm-dd Hh:mi:ss (24h) {2012-08-12 17:26:11}
121 or Yyyy-mm-dd hh:mi:ss.mmm (24h) {2012-08-12 17:26:11.000}

Style ID Style Format
100 or 0 Mon dd yyyy hh:miam (or PM)
101 Mm/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 Mm-dd-yy
111 Yy/mm/dd
112 Yymmdd
113 or 13 DD Mon yyyy hh:mm:ss:mmm (24h)
114 Hh:mi:ss:mmm (24h)
120 or 20 Yyyy-mm-dd Hh:mi:ss (24h)
121 or 21 Yyyy-mm-dd hh:mi:ss.mmm (24h)
126 Yyyy-mm-ddthh:mm:ss.mmm (no spaces)
130 DD Mon yyyy hh:mi:ss:mmmAM
131 Dd/mm/yy Hh:mi:ss:mmmAM

sql2008-characters to numbers cast and convert

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.