Date_format (Date,format)
Formats the date value according to the format string. The following modifiers can be used in the format string:%M month name (January ... December)%W week name (Sunday ... Saturday)%d The date of the month with English prefixes (1st, 2nd, 3rd, etc.). )%Y year, number, 4-digit%Y year, number, 2-bit%a abbreviated weekday name (Sun ... Sat)%d days in the month, number (00 ... %e number of days in the month, number (0 ... %m months, numbers (01 ... %c month, number (1 ... %b Abbreviated month name (Jan ... DEC)%j Days of the year (001 ... 366)%H hours (00 ... %k hours (0 ...) %h hours (01 ...) %I) Hours (01 ... %l hours (1 ...) %i minutes, Numbers (00 ...) %r time, 12 hours (Hh:mm:ss [ap]m)%T time, 24 hours (hh:mm:ss)%s seconds (00 ... ()%s seconds (00 ... %p am or pm%w one days of the week (0=sunday ... 6=saturday)%u week (0 ... 52), here Sunday is the first day of the week%u week (0 ... 52), here Monday is the first day of the week with a text "%". All other characters are not interpreted as being copied into the results. Mysql> Select Date_format (' 1997-10-04 22:23:00 ', '%W%M%Y ');-> ' Saturday October 1997 ' Mysql> Select Date_format (' 1997-10-04 22:23:00 ', '%h:%i:%s ');-> ' 22:23:00 ' mysql> select Date_format (' 1997-10-04 22:23:00 ', '%d%y%a%d%m%b %j ');-> ' 4th Sat in Oct 277 ' mysql> Select Date_format (' 1997-10-04 22:23:00 ', '%H%k%I%r%T%s%w ');-> ' 22 In 10:23:00 PM 22:23:00 6 ' MySQL3.23,% is required before the format modifier character. In the earlier version of MySQL,% is optional.
MySQL part of the date taken