MySQL Variables date_format 数据库 参数变量解释及正确配置使用
本站中文解释
date_format是MySQL中的一个参数变量,用来指定日期的显示格式。
要设置date_format,需要使用下面的SQL语句:
SET GLOBAL date_format=’格式值’;
其中,格式值可以包含如下字符:
%a Abbreviated weekday name (Sun..Sat)
%b Abbreviated month name (Jan..Dec)
%c Month, numeric (0..12)
%d Day of the month, numeric (00..31)
%e Day of the month, numeric (0..31)
%H Hour (00..23)
%I Hour (01..12)
%j Day of year (001..366)
%k Hour (0..23)
%l Hour (1..12)
%o ISO year
%p AM or PM
%r Time, 12-hour (hh:mm:ss followed by AM or PM)
%T Time, 24-hour (hh:mm:ss)
%U Week (00..53), where Sunday is the first day of the week
%W Week (00..53), where Monday is the first day of the week
%u Week (00..53), where Monday is the first day of the week
%V Week (01..53), where Sunday is the first day of the week
%X Year for the week, numeric, four digits
%Y Year, numeric, four digits
另外,还可以使用comma(逗号)和space(空格)来控制输出的空间,其语法为:
“, ” 和 ” ” 。
下面是一个示例来展示如何使用date_format变量:
SET GLOBAL date_format=’%d-%m-%y %T’;
这将会把后续SELECT出的结果的日期格式变为“DD-MM-YY HH:MM:SS”。
官方英文解释
date_format
This variable is unused. It is deprecated and is removed in
MySQL 8.0.