无论如何可以从月份(1-12)中获得MONTHNAME()
?例如,如果我有 6,7,8
,MySQL 中是否有任何本地方式将它们转换为 June,July,August
?
Is there anyway to get the MONTHNAME()
from just the number of the month (1-12)? For example if I have 6,7,8
is there any native way in MySQL to transform those into June,July,August
?
您可以使用 STR_TO_DATE()
将数字转换为日期,然后返回 MONTHNAME()
SELECT MONTHNAME(STR_TO_DATE(6, '%m'));
+---------------------------------+
| MONTHNAME(STR_TO_DATE(6, '%m')) |
+---------------------------------+
| June |
+---------------------------------+
警告:如果在很多行上完成,这可能会很慢.
Warning: This could be slow if done over a lot of rows.
这篇关于MySQL MONTHNAME() 来自数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!