Mega Code Archive

 
Categories / MySQL / Date Time
 

Formatting Dates and Times

mysql> DATE_FORMAT(date, format) helps in representing dates and times in other formats than the usual MySQL format. mysql> mysql> select DATE_FORMAT('2003-12-31','%M %d %Y'); +--------------------------------------+ | DATE_FORMAT('2003-12-31','%M %d %Y') | +--------------------------------------+ | December 31 2003                     | +--------------------------------------+ 1 row in set (0.00 sec) mysql> mysql> select DATE_FORMAT('2003-12-31', '%D of %M'); +---------------------------------------+ | DATE_FORMAT('2003-12-31', '%D of %M') | +---------------------------------------+ | 31st of December                      | +---------------------------------------+ 1 row in set (0.00 sec) mysql>