Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get month name from month number [duplicate]

Tags:

I can get the next month's month number and year with:

(Time.now + 1.month).month # => 10 (Time.now + 1.month).year # => 2015 

How can I get "October" from 10?

like image 420
Michael Durrant Avatar asked Sep 03 '15 12:09

Michael Durrant


People also ask

How do I convert month number to month name?

An alternative way to get a month number from an Excel date is using the TEXT function: =TEXT(A2, "m") - returns a month number without a leading zero, as 1 - 12. =TEXT(A2,"mm") - returns a month number with a leading zero, as 01 - 12.

How can get month name from month number in SQL?

In MySQL, we can use a combination of functions 'MONTHNAME' and 'STR_TO_DATE' functions to get a month name from a month number. SQL SERVER: In SQL SERVER, we can use a combination of functions 'DATENAME' and 'DATEADD' functions to get a month name from a month number.

How do I convert a number to a month name in Excel?

Select a cell(s) with dates, press Ctrl+1 to opent the Format Cells dialog. On the Number tab, select Custom and type either "mmm" or "mmmm" in the Type box to display abbreviated or full month names, respectively.


1 Answers

You can use Date's monthnames constant

Date::MONTHNAMES[10] => "October" 
like image 186
j-dexx Avatar answered Oct 03 '22 16:10

j-dexx