How can I get the month name from the month number?
For instance, if I have 3
, I want to return march
date.tm_month()
How to get the string march
?
The MONTH function takes just one argument, the date from which to extract the month. In the example shown, the formula is: = MONTH ( B4 ) where B4 contains the dateJanuary 5, 2016. The MONTH function returns the number 1 representing the month(...
Please do as follows: Select a blank cell next to the sales table, type the formula =TEXT(A2*29,"mmm") (Note: A2 is the first number of the Month list you will convert to month name), and then drag the AutoFill Handle down to other cells. Now you will see the numbers (from 1 to 12) are converted to normal month names.
import datetime mydate = datetime.datetime.now() mydate.strftime("%B")
Returns: December
Some more info on the Python doc website
[EDIT : great comment from @GiriB] You can also use %b
which returns the short notation for month name.
mydate.strftime("%b")
For the example above, it would return Dec
.
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