date[/code][/i],[i][code]format[/code][/i])
Formats the [i][code]date[/code][/i] value according to the [i][code]format[/code][/i] string.
The following specifiers may be used in the [i][code]format[/code][/i] string. As of MySQL 3.23, the “[code]%[/code]” character is required before format specifier characters. In earlier versions of MySQL, “[code]%[/code]” was optional.
| Specifier | Description |
|---|---|
| [code]%a[/code] | Abbreviated weekday name ([code]Sun[/code]..[code]Sat[/code]) |
| [code]%b[/code] | Abbreviated month name ([code]Jan[/code]..[code]Dec[/code]) |
| [code]%c[/code] | Month, numeric ([code]0[/code]..[code]12[/code]) |
| [code]%D[/code] | Day of the month with English suffix ([code]0th[/code], [code]1st[/code], [code]2nd[/code], [code]3rd[/code], …) |
| [code]%d[/code] | Day of the month, numeric ([code]00[/code]..[code]31[/code]) |
| [code]%e[/code] | Day of the month, numeric ([code]0[/code]..[code]31[/code]) |
| [code]%f[/code] | Microseconds ([code]000000[/code]..[code]999999[/code]) |
| [code]%H[/code] | Hour ([code]00[/code]..[code]23[/code]) |
| [code]%h[/code] | Hour ([code]01[/code]..[code]12[/code]) |
| [code]%I[/code] | Hour ([code]01[/code]..[code]12[/code]) |
| [code]%i[/code] | Minutes, numeric ([code]00[/code]..[code]59[/code]) |
| [code]%j[/code] | Day of year ([code]001[/code]..[code]366[/code]) |
| [code]%k[/code] | Hour ([code]0[/code]..[code]23[/code]) |
| [code]%l[/code] | Hour ([code]1[/code]..[code]12[/code]) |
| [code]%M[/code] | Month name ([code]January[/code]..[code]December[/code]) |
| [code]%m[/code] | Month, numeric ([code]00[/code]..[code]12[/code]) |
| [code]%p[/code] | [code]AM[/code] or [code]PM[/code] |
| [code]%r[/code] | Time, 12-hour ([code]hh:mm:ss[/code] followed by [code]AM[/code] or [code]PM[/code]) |
| [code]%S[/code] | Seconds ([code]00[/code]..[code]59[/code]) |
| [code]%s[/code] | Seconds ([code]00[/code]..[code]59[/code]) |
| [code]%T[/code] | Time, 24-hour ([code]hh:mm:ss[/code]) |
| [code]%U[/code] | Week ([code]00[/code]..[code]53[/code]), where Sunday is the first day of the week |
| [code]%u[/code] | Week ([code]00[/code]..[code]53[/code]), where Monday is the first day of the week |
| [code]%V[/code] | Week ([code]01[/code]..[code]53[/code]), where Sunday is the first day of the week; used with [code]%X[/code] |
| [code]%v[/code] | Week ([code]01[/code]..[code]53[/code]), where Monday is the first day of the week; used with [code]%x[/code] |
| [code]%W[/code] | Weekday name ([code]Sunday[/code]..[code]Saturday[/code]) |
| [code]%w[/code] | Day of the week ([code]0[/code]=Sunday..[code]6[/code]=Saturday) |
| [code]%X[/code] | Year for the week where Sunday is the first day of the week, numeric, four digits; used with [code]%V[/code] |
| [code]%x[/code] | Year for the week, where Monday is the first day of the week, numeric, four digits; used with [code]%v[/code] |
| [code]%Y[/code] | Year, numeric, four digits |
| [code]%y[/code] | Year, numeric (two digits) |
| [code]%%[/code] | A literal “[code]%[/code]” character |
[code]%[i]x[/code][/i] |
[i][code]x[/code][/i], for any “[i][code]x[/code][/i]” not listed above |
mysql> [code]SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');[/code]
-> 'Sunday October 2009'
mysql> [code]SELECT DATE_FORMAT('2007-10-04 22:23:00', '%H:%i:%s');[/code]
-> '22:23:00'
mysql> [code]SELECT DATE_FORMAT('1900-10-04 22:23:00',[/code]
-> [code] '%D %y %a %d %m %b %j');[/code]
-> '4th 00 Thu 04 10 Oct 277'
mysql> [code]SELECT DATE_FORMAT('1997-10-04 22:23:00',[/code]
-> [code] '%H %k %I %r %T %S %w');[/code]
-> '22 22 10 10:23:00 PM 22:23:00 00 6'
mysql> [code]SELECT DATE_FORMAT('1999-01-01', '%X %V');[/code]
-> '1998 52'
mysql> [code]SELECT DATE_FORMAT('2006-06-00', '%d');[/code]
-> '00'[/*]
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有