Date and Time format in SQL
In SQL we have date and time format to show the date and time format in different ways lets see what are the date and time formats are there.
1.Date and Time format in SQL
Formate | Query | Sample |
---|---|---|
1 | select convert(varchar,getdate(),1) | 12/30/08 |
2 | select convert(varchar,getdate(),2) | 08.12.30 |
3 | select convert(varchar,getdate(),3) | 30/12/08 |
4 | select convert(varchar,getdate(),4) | 30.12.08 |
5 | select convert(varchar,getdate(),5) | 30-12-08 |
6 | select convert(varchar,getdate(),6) | 30 Dec 08 |
7 | select convert(varchar,getdate(),7) | Dec 30 08 |
10 | select convert(varchar,getdate(),10) | 12-30-08 |
11 | select convert(varchar,getdate(),11) | 08/12/30 |
12 | select convert(varchar,getdate(),12) | 08 12 30 |
23 | select convert(varchar,getdate(),23) | 2008-12-30 |
101 | select convert(varchar,getdate(),101) | 12/30/2008 |
102 | select convert(varchar,getdate(),102) | 2008.12.30 |
103 | select convert(varchar,getdate(),103) | 30/12/2008 |
104 | select convert(varchar,getdate(),104) | 30.12.2008 |
105 | select convert(varchar,getdate(),105) | 30-12-2008 |
106 | select convert(varchar,getdate(),106) | 30 Dec 2008 |
107 | select convert(varchar,getdate(),107) | Dec 30 2008 |
110 | select convert(varchar,getdate(),110) | 12/30/2008 |
111 | select convert(varchar,getdate(),111) | 2008/12/30 |
112 | select convert(varchar,getdate(),112) | 2008 12 30 |
Time only format:-
In SQL have some time only format lets see what are time format are there :-Formate | Query | Sample |
---|---|---|
8 | select convert(varchar,getdate(),8) | 00:38:53 |
14 | select convert(varchar,getdate(),14) | 00:38:53:840 |
24 | select convert(varchar,getdate(),24) | 00:38:53 |
108 | select convert(varchar,getdate(),108) | 00:38:53 |
114 | select convert(varchar,getdate(),114) | 00:38:53:840 |