MySql time DATE_FORMAT(date,format)
DATE_FORMAT(date,format)
如: select DATE_FORMAT(data_time,"%Y-%m-%d %H:%m:%s") from xxx where data_time='2020-12-01 12:30:45'
The format of the format parameter is
%a | Abbreviated weekday |
---|---|
%b | Abbreviated month name |
%c | Month, number |
%D | Day of the month with English prefix |
%d | Day of month, numeric value (00-31) |
%e | Day of month, numeric value (0-31) |
%f | Microsecond |
%H | Hour (00-23) |
%h | Hour (01-12) |
%I | Hour (01-12) |
%i | Minutes, number (00-59) |
%j | Day of the year (001-366) |
%k | Hour (0-23) |
%l | Hour (1-12) |
%M | Month name |
%m | Month, number (00-12) |
%p | AM or PM |
%r | Time, 12-hour (hh:mm:ss AM or PM) |
%S | Seconds (00-59) |
%s | Seconds (00-59) |
%T | Time, 24-hours (hh:mm:ss) |
% U | Week (00-53) Sunday is the first day of the week |
% u | Week (00-53) Monday is the first day of the week |
% V | Week (01-53) Sunday is the first day of the week, used with %X |
% v | Week (01-53) Monday is the first day of the week, used with %x |
%W | Week name |
%w | Day of the week (0=Sunday, 6=Saturday) |
%X | Year, where Sunday is the first day of the week, 4 digits, used with %V |
%x | Year, where Monday is the first day of the week, 4 digits, used with %v |
%AND | Years, 4 digits |
%and | Year, 2 digits |