Best Answer · By JanBask MS SQL Server Expert
Answered on Nov 1, 2019
Below is the table describing the each converted:
Query syntax: select convert (varchar, date, format number)
Sample Query: select convert (varchar, getdate(), 0)
Required format/ Output received
Format number
Return type
Mar 5 2020 2:03PM
0
date and time
03/05/20
1
Date
20.03.05
2
Date
05/03/20
3
Date
05.03.20
4
Date
05-03-20
5
Date
05 Mar 20
6
Date
Mar 05, 20
7
Date
14:03:40
8
Only time
Mar 5 2020 2:03:40:740PM
9
date and time
03-05-20
10
Date
20/03/05
11
Date
200305
12
Date
05 Mar 2020 14:03:40:740
13
date and time
14:03:40:740
14
Only time
2020-03-05 14:03:40
20
date and time
2020-03-05 14:03:40.740
21
date and time
03/05/20 2:03:40 PM
22
date and time
2020-03-05
23
Date
14:03:40
24
Only time
2020-03-05 14:03:40.740
25
date and time
Mar 5 2020 2:03PM
100
date and time
03/05/2020
101
Date
2020.03.05
102
Date
05/03/2020
103
Date
05.03.2020
104
Date
05-03-2020
105
Date
05 Mar 2020
106
Date
Mar 05, 2020
107
Date
14:03:40
108
Only time
Mar 5 2020 2:03:40:740PM
109
date and time
03-05-2020
110
Date
2020/03/05
111
Date
20200305
112
Date
05 Mar 2020 14:03:40:740
113
date and time
14:03:40:740
114
Only time
2020-03-05 14:03:40
120
date and time
2020-03-05 14:03:40.740
121
date and time
2020-03-05T14:03:40.740
126
date and time
2020-03-05T14:03:40.740
127
date and time