How to use the MONTH function
The MONTH function extracts the month as a number from an Excel date.
- 1 - January
- 2 - February
- 3 - March
- 4 - April
- 5 - May
- 6 - June
- 7 - July
- 8 - August
- 9 - September
- 10 - October
- 11 - November
- 12 - December
Table of Contents
1. MONTH Function Syntax
MONTH(serial_number)
2. MONTH Function Arguments
serial_number | Required. The date value you want to extract the month from. |
3. MONTH Function not working
Check your spelling, the image above shows the MONTH function misspelled. An #NAME? error is shown in cell C3.
Cell B3 contains a text value and not a proper Excel date, this returns a #VALUE! error in cell C3.
4. MONTH Function example
Formula in cell C3:
To understand the MONTH function I need to explain that it needs an Excel date in order to calculate the month properly. The date in cell B3 is an Excel date meaning it is a number formatted as a date. 1 is 1/1/1900 and 1/1/2000 is 36526 meaning there are 36526 days between the dates.
You can verify this, select a cell containing 1/1/2000 and press CTRL + 1 to open the "Format Cells" dialog box.
The "Sample" shown in the image above demonstrates what the value changes to if you choose to format the cells using the category "General". The sample contains 36526 which is the number representing 1/1/2000.
5. MONTH Function alternative
Formula in cell C3:
Explaining formula
Step 1 - TEXT function
The TEXT function lets you format values.
TEXT(value, format_text)
value - The string you want to format. You can use a cell reference here or use a text string.
format_text - Formatting code allowing you to change the way, for example, a date or a number is displayed to the Excel user.
Step 2 - Populate arguments
The TEXT function has two arguments.
value - B3
format_text - "m"
"m" is an abbreviation for month. A single "m" returns the number representing the position of a given month in a year.
Check out this article to learn more about formatting codes in the TEXT function.
Step 3 - Evaluate TEXT function
TEXT(B3, "m")
becomes
TEXT(45089, "m")
and returns 6. 6 represents the sixth month in a year which is "June".
6. MONTH function - return month name instead of a number
6.1 Example 1 - INDEX function
Formula in cell C3:
Explaining formula in cell C3
Step 1 - Calculate month number
MONTH(B3)
- 1 - January
- 2 - February
- 3 - March
- 4 - April
- 5 - May
- 6 - June
- 7 - July
- 8 - August
- 9 - September
- 10 - October
- 11 - November
- 12 - December
MONTH(B3)
becomes
MONTH(45089)
and returns 6. Number 6 represents "June".
Step 2 - Return corresponding month name
The INDEX function returns a value in a cell range or array based on a row and column number (optional).
INDEX(array, [row_num], [column_num], [area_num])
INDEX({"January"; "February"; "March"; "April"; "May"; "June"; "July"; "August"; "September"; "October"; "November"; "December"},MONTH(B3))
becomes
INDEX({"January"; "February"; "March"; "April"; "May"; "June"; "July"; "August"; "September"; "October"; "November"; "December"}, 6)
and returns "June". "June" is the sixth month in a year.
6.2 Example 2 - TEXT function
Formula in cell C4:
Explaining formula in cell C4
The TEXT function lets you format values.
TEXT(value, format_text)
value - The string you want to format. You can use a cell reference here or use a text string.
format_text - Formatting code allowing you to change the way, for example, a date or a number is displayed to the Excel user.
Formatting code "mmmm" evaluates to the month name.
TEXT(B4, "mmmm")
becomes
TEXT(44603, "mmmm")
and returns "March".
6.3 Example 3 - Cell formatting
You can also show the month name using cell formatting, the image above demonstrates cell formatting applied to cell C5.
How to apply cell formatting:
- Select cell C5.
- Press CTRL + 1 to open the "Format Cells" dialog box.
- Press with left mouse button on "Category" Custom, see the image above.
- Enter mmmm below Type:
- Press with left mouse button on OK button to apply cahnges.
7. Filter dates based on month
Formula in cell D3:
Explaining formula
Step 1 - Calculate month number for each date value
MONTH(B3:B11)
becomes
MONTH({44667; 44667; 44700; 44707; 45006; 45051; 45054; 45075; 45079})
and returns {4; 4; 5; 5; 3; 5; 5; 5; 6}.
Step 2 - Compare month number to condition
The equal sign lets you check if values are equal, note that this does not perform a case-sensitive comparison. Check out the EXACT function if upper and lower letters matter.
MONTH(B3:B11)=5
becomes
{4; 4; 5; 5; 3; 5; 5; 5; 6}=5
and returns
{FALSE; FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE; FALSE}
Step 3 - Extract dates meeting the condition
The FILTER function is a new function available to Excel 365 subscribers. It lets you extract values based on a condition or criteria.
FILTER(array, include, [if_empty])
FILTER(B3:B11, MONTH(B3:B11)=5)
becomes
FILTER({44667; 44667; 44700; 44707; 45006; 45051; 45054; 45075; 45079}, {FALSE; FALSE; TRUE; TRUE; FALSE; TRUE; TRUE; TRUE; FALSE})
and returns {44700; 44707; 45051; 45054; 45075}.
'MONTH' function examples
Introduction In this post I am creating a spreadsheet that will calculate stock portfolio performance. To do this I am […]
Brad asks: I'm trying to use your formulas to create my own bill reminder sheet. I envision a workbook where […]
The formula in cell C3 calculates the last date for the given month and year in cell B3. =DATE(YEAR(B3), MONTH(B3)+1, […]
Functions in 'Date and Time' category
The MONTH function function is one of many functions in the 'Date and Time' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form