The following is a table of constants used in converting date values within SQL. This list is taken from the site of W3C. More information can be found on MSDN.
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 |
They are used as follows:
CONVERT(VARCHAR(24),GETDATE(),113)
No comments:
Post a Comment