MySQL DATE_FORMAT '%M' 短月?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17900458/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 18:19:07  来源:igfitidea点击:

MySQL DATE_FORMAT '%M' for short month?

mysql

提问by user2574794

I'm trying to display dates like this 27-Jul-13. I keep reading that Mshould give the shorthand month and Fthe full name. I am using this:

我正在尝试显示这样的日期27-Jul-13。我继续阅读M应该给出速记月份和F全名。我正在使用这个:

DATE_FORMAT(date, '%d-%M-%y') AS Displaydate

but it displays like this: 14-April-12not 14-Apr-12

但它显示如下:14-April-12不是14-Apr-12

Also if I use Fit doesn't work at all, it just displays an Fwhere the month should be. What am I doing wrong?

此外,如果我使用F它根本不起作用,它只会显示F月份应该在哪里。我究竟做错了什么?

回答by

According to DATE_FORMATdoc, you need %bfor your format:

根据DATE_FORMAT文档,你需要%b你的格式:

DATE_FORMAT(date, '%d-%b-%y') AS Displaydate

回答by Erman Belegu

DATE_FORMAT(date, '%d-%b-%y') AS Displaydate