We can display the date and time data in many different formats using the CONVERT function with different styles.
Example:
Select getdate() Result: 2009-10-26 13:39:59.543
Different style numbers results different format of date time display.
| Style |
Result |
| 0 or 100 |
Oct 26 2009 1:41PM |
| 1 |
10/26/2009 |
| 2 |
09.10.26 |
| 3 |
26/10/09 |
| 4 |
26.10.09 |
| 5 |
26-10-09 |
| 6 |
26 Oct 09 |
| 7 |
Oct 26, 09 |
| 8, 24, or 108 |
13:42:23 |
| 9 or 109 |
Oct 26 2009 1:42:42:543PM |
| 10 |
10-26-09 |
| 11 |
09/10/26 |
| 12 |
091026 |
| 13 |
26 Oct 2009 13:46:14:590 |
| 14 |
13:46:25:967 |
| 20 |
2009-10-26 13:48:51 |
| 21 or 25 |
2009-10-26 13:48:29.340 |
| 22 |
10/26/09 1:48:53 PM |
| 23 |
2009-10-26 |
| 24 |
13:48:53 |
| 101 |
10/26/2009 |
| 102 |
2009.10.26 |
| 103 |
26/10/2009 |
| 104 |
26.10.2009 |
| 105 |
26-10-2009 |
| 106 |
26 Oct 2009 |
| 107 |
Oct 26, 2009 |
| 110 |
10-26-2009 |