How to return a DATETIME in those formats
I have a field on a MySql table with DATETIME data, and I'd开发者_如何学运维 like to select these data in some formats.
For example, I'd like to extract 2011-04-02 00:30:02
it in these ways :
- 02/04/2011 - 00:30:02
- 02/04 - 00:30:02
- 02/04/2011
- 00:30:02
using only MySql instruments.
Is it possible? Can you give to me an example?
select date_format(date_column, '%d/%c/%Y - %H:%i:%s');
for a list of all the modifiers see http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
yes, you can do it using the DATE_FORMAT
mysql function
Please check MySQL's date_format
function.
精彩评论