Question:
MySql and Formatting Dates?
jeff lemon
2007-08-12 16:10:47 UTC
In a mysql query, ho can I turn this date format that is in the DB:

2007-02-13

Into

13 February 2007?

Many Thanks
Three answers:
Phil
2007-08-12 16:31:48 UTC
Thanks for asking this question!



When you select, use the DATE_FORMAT function, with the proper "mask". In your case its:



SELECT DATE_FORMAT(mydate, "%d %M %Y") AS formatted_date FROM mytable



Good luck!
?
2016-11-12 08:43:20 UTC
The format for a date in mysql is YYYY-MM-DD HH:mm:ss. it somewhat is stored, despite the fact that, in timestamp format (Unix). you could "prepare" the date before putting it: $datum = date ("Y-M-D H:i:s", strtotime ("sixteen/12/2009 22:22:22")); beware: strtotime could confuse 01/02/2009: 1st feb OR jan 2d...
2007-08-12 16:17:26 UTC
Look up the php or asp manual for date formatting, depending on your software. There is no simple effective date formatting for this in mysql.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...