October 2002
Beginner
864 pages
18h 41m
English
Sybase and Microsoft's SQL Server can insert dates into a table in various formats; they can also extract dates in several different types of formats. This section shows you how to use SQL Server's CONVERT command to manipulate the way a date is displayed.
CONVERT (datatype [(length)], expression, format)
The following date formats are available with SQL Server when using the CONVERT function:
| Format Code | Format Picture |
|---|---|
| 100 | mon dd yyyy hh:miAM/PM |
| 101 | mm/dd/yy |
| 102 | yy.mm.dd |
| 103 | dd/mm/yy |
| 104 | dd.mm.yy |
| 105 | dd-mm-yy |
| 106 | dd mon yy |
| 107 | mon dd, yy |
| 108 | hh:mi:ss |
| 109 | mon dd, yyyy hh:mi:ss:mmmAM/PM |
| 110 | mm-dd-yy |
| 111 | yy/mm/dd |
| 112 | yymmdd |
select "PayDate" = convert(char(15), paydate, 107) from payment_table where customer_id = 012845 PayDate --------------- May 1, 97 ...
Read now
Unlock full access