开发者

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 :

  1. 02/04/2011 - 00:30:02
  2. 02/04 - 00:30:02
  3. 02/04/2011
  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜