mysql monthname from numbers

mysql monthname from numbers  using -'mysql'

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?

asked Sep 29, 2015 by santosh soni
0 votes

2 Answers

0 votes

Before reading Michael's great answer I had thought something like this

select elt(3,'January','February','March',....)

but his one is much better. :)

answered Sep 29, 2015 by deepak07.s
0 votes

You can use STR_TO_DATE() to convert the number to a date, and then back with MONTHNAME()


| June                            |

Warning: This could be slow if done over a lot of rows.

answered Sep 29, 2015 by rajeevr642