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
?
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.
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.
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.
You can use Date's monthnames constant
Date::MONTHNAMES[10] => "October"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With