MySQL's DATE_FORMAT function does exactly this. Again, from the reference section of the upcoming book (apologies for the poorly formatted table -- I'm in a bit of a hurry):
DATE_FORMAT(date,format)
Takes the date or time value date and returns it formatted according to the formatting string format, which may contain any of the following symbols as placeholders shown in Table 2.
Table 2 – DATE_FORMAT() symbols (example: 2001-01-01 01:00:00)
Code:
Symbol Displays Example
%M Month name January
%W Weekday name Monday
%D Day of the month with English suffix 1st
%Y Year, numeric, 4 digits 2001
%y Year, numeric, 2 digits 01
%X Year for the week where Sunday is the 1st day of the week, 4 digits (use with %V) 2001
%x Like %X, Monday 1st day of the week (%v) 2001
%a Abbreviated weekday name Mon
%d Day of the month 01
%e Day of the month 1
%m Month of the year, numeric 01
%c Month of the year, numeric 1
%b Abbreviated month name Jan
%j Day of the year 001
%H Hour of the day (24-hour format, 00-23) 01
%k Hour of the day (24-hour format, 0-23) 1
%h Hour of the day (12-hour format, 01-12) 01
%I Hour of the day (12-hour format, 01-12) 01
%l Hour of the day (12-hour format, 1-12) 1
%i Minutes 00
%r Time, 12-hour (hh:mm:ss: AM/PM) 01:00:00 AM
%T Time, 24-hour (hh:mm:ss) 01:00:00
%S Seconds 00
%s Seconds 00
%p AM or PM AM
%w Day of the week, numeric (0=Sunday) 1
%U Week (00-53), Sunday 1st day of the week 01
%u Week (00-53), Monday 1st day of the week 01
%V Week (1-53), Sunday 1st day of week (%X) 01
%v Week (1-53), Monday 1st day of week (%x) 01
%% An actual percent sign %
Bookmarks