简体   繁体   English

同时使用 MONTHNAME 和 DATE_FORMAT

[英]Using MONTHNAME and DATE_FORMAT together

I'm retrieving and storing a Date field from a database.我正在从数据库中检索和存储日期字段。 On the graph I want to print only the "day of month" with month_name在图表上,我只想用 month_name 打印“月份中的某天”
DATE_FORMAT and MONTHNAME does the job, but not together. DATE_FORMAT 和 MONTHNAME 可以完成这项工作,但不能一起完成。 Any alternatives for the problem?该问题的任何替代方案?

INPUT: 2015-02-20 00:00:10

OUTPUT: 20th Feb

Since you're mentioning Oracle:既然你提到了甲骨文:

SELECT TO_CHAR(to_timestamp('2015-02-20 00:00:10','YYYY-MM-DD HH24:MI:SS'),'ddth Mon')
FROM dual

Since I no longer see the Oracle reference mentioned by Marius, here's a MySQL option:由于我不再看到 Marius 提到的 Oracle 参考,这里有一个 MySQL 选项:

select date_format('2015-02-20 00:00:10','%D %b');

Returns:返回:

20th Feb

Here are some other formatting options for the date_format function.以下是 date_format 函数的一些其他格式选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM