How to Convert Between Month Name & Number in Google Sheets
There are several ways to convert between month names and numbers in Google Sheets. Let's explore a few methods.
Method 1: Using the MONTH and DATE functions
- Convert month name to month number:
- Formula:
=MONTH(DATEVALUE("MonthName&" 1"))
- Replace "MonthName" with the actual month name or the cell reference containing the month name.
- Formula:
- Convert month number to month name:
- Formula:
=TEXT(DATE(2022, MonthNumber, 1), "MMMM")
- Replace "MonthNumber" with the actual month number or the cell reference containing the month number.
- Formula:
Method 2: Using the SWITCH function
- Convert month name to month number:
- Formula:
=SWITCH(MONTH_NAME, "January", 1, "February", 2, "March", 3, "April", 4, "May", 5, "June", 6, "July", 7, "August", 8, "September", 9, "October", 10, "November", 11, "December", 12)
- Replace MONTH_NAME with the actual month name or the cell reference containing the month name.
- Formula:
- Convert month number to month name:
- Formula:
=SWITCH(MONTH_NUMBER, 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December")
- Replace MONTH_NUMBER with the actual month number or the cell reference containing the month number.
- Formula:
Example
Let's say we have a month name in cell A1 and a month number in cell B1. Here's how to convert them using the MONTH and DATE functions:
- Convert month name (A1) to month number:
- Formula in cell C1:
=MONTH(DATEVALUE(A1&" 1"))
- Formula in cell C1:
- Convert month number (B1) to month name:
- Formula in cell D1:
=TEXT(DATE(2022, B1, 1), "MMMM")
- Formula in cell D1:
Now, let's convert them using the SWITCH function:
- Convert month name (A1) to month number:
- Formula in cell E1:
=SWITCH(A1, "January", 1, "February", 2, "March", 3, "April", 4, "May", 5, "June", 6, "July", 7, "August", 8, "September", 9, "October", 10, "November", 11, "December", 12)
- Formula in cell E1:
- Convert month number (B1) to month name:
- Formula in cell F1:
=SWITCH(B1, 1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", 7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December")
- Formula in cell F1:
Did you find this useful?