SQL Date Conversions - More Than You Want To Know
Today I was writing a query that performed some date formatting and found myself using this resource by Manuj Bahl, to which I've often referred but to which I've rarely given any thought. By dumb luck, I fat-fingered one of the codes and ended up with something not listed on the table, but the query ran fine.
Curiousity sufficiently piqued, I wrote a simple Coldfusion script, and a few seconds later found myself looking at a complete table of date/time conversion codes. Most of them are not terribly useful, but in case anyone wants an exhaustive list of every conversion code available, you'll find it behind the cut.
I should note that I use SQL Server 2000, so results may and almost certainly will vary among products/versions.
On an even-less-interesting note, it would appear that the conversion code is restricted to 8 bits, since a value of 256, 512, etc gives the same result as 0, and the same applies to the rest of the list.
The table lists each conversion code and its output given a date/time of March 15, 2008 1:23:45 PM.
Code | Output |
---|---|
0 | Mar 15 2008 1:23PM |
1 | 03/15/08 |
2 | 08.03.15 |
3 | 15/03/08 |
4 | 15.03.08 |
5 | 15-03-08 |
6 | 15 Mar 08 |
7 | Mar 15, 08 |
8 | 13:23:45 |
9 | Mar 15 2008 1:23:45:000PM |
10 | 03-15-08 |
11 | 08/03/15 |
12 | 080315 |
13 | 15 Mar 2008 13:23:45:000 |
14 | 13:23:45:000 |
20 | 2008-03-15 13:23:45 |
21 | 2008-03-15 13:23:45.000 |
22 | 03/15/08 1:23:45 PM |
23 | 2008-03-15 |
24 | 13:23:45 |
25 | 2008-03-15 13:23:45.000 |
100 | Mar 15 2008 1:23PM |
101 | 03/15/2008 |
102 | 2008.03.15 |
103 | 15/03/2008 |
104 | 15.03.2008 |
105 | 15-03-2008 |
106 | 15 Mar 2008 |
107 | Mar 15, 2008 |
108 | 13:23:45 |
109 | Mar 15 2008 1:23:45:000PM |
110 | 03-15-2008 |
111 | 2008/03/15 |
112 | 20080315 |
113 | 15 Mar 2008 13:23:45:000 |
114 | 13:23:45:000 |
120 | 2008-03-15 13:23:45 |
121 | 2008-03-15 13:23:45.000 |
126 | 2008-03-15T13:23:45 |
130 | 8 ???? ????? 1429 1:23:45:00 |
131 | 8/03/1429 1:23:45:000PM |
There are no comments for this entry.
[Add Comment]