format:
Convert (Data_Type, Expression [, Style])
Description:
This style is typically in time type (DateTime, SmallDateTime) with string type (nchar, nvarchar, char, varchar)
It is used when converting each other.
example:
Select Convert (VARCHAR (30), Getdate (), 101) Now
Resulting
NOW
---------------------------------------
09/15/2001
/
STYLE number The meaning of the conversion time is as follows
-------------------------------------------------- -----------------------------------------------
Style (2nd represents year) | style (4 digits year) | Input Output Format
-------------------------------------------------- -----------------------------------------------
- | 0 OR 100 | MON DD YYYY HH: MIAM (or PM)
-------------------------------------------------- -----------------------------------------------
1 | 101 | MM / DD / YY
-------------------------------------------------- -----------------------------------------------
2 | 102 | YY-MM-DD
-------------------------------------------------- -----------------------------------------------
3 | 103 | DD / MM / YY
-------------------------------------------------- -----------------------------------------------
4 | 104 | DD-MM-YY
-------------------------------------------------- -----------------------------------------------
5 | 105 | DD-MM-YY
-------------------------------------------------- -----------------------------------------------
6 | 106 | DD MON YY
-------------------------------------------------- -----------------------------------------------
7 | 107 | MON DD, YY
-------------------------------------------------- ------------------------------------------------ 8 | 108 | Hh: mm: ss
-------------------------------------------------- -----------------------------------------------
- | 9 or 109 | MON DD YYYY HH: MI: SS: Mmmmam (or PM)
-------------------------------------------------- -----------------------------------------------
10 | 110 | MM-DD-YY
-------------------------------------------------- -----------------------------------------------
11 | 111 | YY / MM / DD
-------------------------------------------------- -----------------------------------------------
12 | 112 | YYMMDD
-------------------------------------------------- -----------------------------------------------
- | 13 or 113 | DD MON YYYY HH: MI: SS: MMM (24 hours)
-------------------------------------------------- -----------------------------------------------
14 | 114 | HH: MI: SS: MMM (24 hours)
-------------------------------------------------- -----------------------------------------------
- | 20 OR 120 | YYYY-MM-DD HH: MI: SS (24-hour)
-------------------------------------------------- -----------------------------------------------
- | 21 or 121 | YYYY-MM-DD HH: MI: SS: MMM (24-hour system)
-------------------------------------------------- -----------------------------------------------