sqlserver 时间字段select格式化
-
日期格式化
# Query Format Sample 1 select convert(varchar, {column}, 1) mm/dd/yy 12/30/06 2 select convert(varchar, {column}, 2) yy.mm.dd 06.12.30 3 select convert(varchar, {column}, 3) dd/mm/yy 30/12/06 4 select convert(varchar, {column}, 4) dd.mm.yy 30.12.06 5 select convert(varchar, {column}, 5) dd-mm-yy 30-12-06 6 select convert(varchar, {column}, 6) dd-Mon-yy 30 Dec 06 7 select convert(varchar, {column}, 7) Mon dd, yy Dec 30, 06 10 select convert(varchar, {column}, 10) mm-dd-yy 12-30-06 11 select convert(varchar, {column}, 11) yy/mm/dd 06/12/30 12 select convert(varchar, {column}, 12) yymmdd 061230 23 select convert(varchar, {column}, 23) yyyy-mm-dd 2006-12-30 101 select convert(varchar, {column}, 101) mm/dd/yyyy 12/30/2006 102 select convert(varchar, {column}, 102) yyyy.mm.dd 2006.12.30 103 select convert(varchar, {column}, 103) dd/mm/yyyy 30/12/2006 104 select convert(varchar, {column}, 104) dd.mm.yyyy 30.12.2006 105 select convert(varchar, {column}, 105) dd-mm-yyyy 30-12-2006 106 select convert(varchar, {column}, 106) dd Mon yyyy 30 Dec 2006 107 select convert(varchar, {column}, 107) Mon dd, yyyy Dec 30, 2006 110 select convert(varchar, {column}, 110) mm-dd-yyyy 12-30-2006 111 select convert(varchar, {column}, 111) yyyy/mm/dd 2006/12/30 112 select convert(varchar, {column}, 112) yyyymmdd 20061230 -
时间格式化
# Query Format Sample 8 select convert(varchar, {column}, 8) hh:mm:ss 00:38:54 14 select convert(varchar, {column}, 14) hh:mm:ss:nnn 00:38:54:840 24 select convert(varchar, {column}, 24) hh:mm:ss 00:38:54 108 select convert(varchar, {column}, 108) hh:mm:ss 00:38:54 114 select convert(varchar, {column}, 114) hh:mm:ss:nnn 00:38:54:840 -
日期时间格式化
# Query Format Sample 0 select convert(varchar, {column}, 0) Mon dd yyyy hh:mm AM/PM Dec 30 2006 12:38AM 9 select convert(varchar, {column}, 9) Mon dd yyyy hh:mm:ss:nnn AM/PM Dec 30 2006 12:38:54:840AM 13 select convert(varchar, {column}, 13) dd Mon yyyy hh:mm:ss:nnn AM/PM 30 Dec 2006 00:38:54:840AM 20 select convert(varchar, {column}, 20) yyyy-mm-dd hh:mm:ss 2006-12-30 00:38:54 21 select convert(varchar, {column}, 21) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840 22 select convert(varchar, {column}, 22) mm/dd/yy hh:mm:ss AM/PM 12/30/06 12:38:54 AM 25 select convert(varchar, {column}, 25) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840 100 select convert(varchar, {column}, 100) Mon dd yyyy hh:mm AM/PM Dec 30 2006 12:38AM 109 select convert(varchar, {column}, 109) Mon dd yyyy hh:mm:ss:nnn AM/PM Dec 30 2006 12:38:54:840AM 113 select convert(varchar, {column}, 113) dd Mon yyyy hh:mm:ss:nnn 30 Dec 2006 00:38:54:840 120 select convert(varchar, {column}, 120) yyyy-mm-dd hh:mm:ss 2006-12-30 00:38:54 121 select convert(varchar, {column}, 121) yyyy-mm-dd hh:mm:ss:nnn 2006-12-30 00:38:54.840 126 select convert(varchar, {column}, 126) yyyy-mm-dd T hh:mm:ss:nnn 2006-12-30T00:38:54.840 127 select convert(varchar, {column}, 127) yyyy-mm-dd T hh:mm:ss:nnn 2006-12-30T00:38:54.840