How to use the MONTH function
What is the MONTH function?
The MONTH function returns a number representing the month 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. Introduction
What is an Excel date?
Dates are stored numerically but formatted to display in human-readable date/time formats, this enables Excel to do work with dates in calculations.
For example, dates are stored as sequential serial numbers with 1 being January 1, 1900 by default. The integer part (whole number) represents the date the decimal part represents the time.
This allows dates to easily be formatted to display in many date/time formats like mm/dd/yyyy, dd/mm/yyyy and so on and still be part of calculations as long as the date is stored numerically in a cell.
You can try this yourself, type 10000 in a cell, press CTRL + 1 and change the cell's formatting to date, press with left mouse button on OK. The cell now shows 5/18/1927.
Why are dates actually integers in Excel?
This allows for calculations like adding or subtracting days to a given date. It also allows for easy formatting meaning you can customize the look of a given date by formatting the cell to your needs.
2. Syntax
MONTH(serial_number)
serial_number | Required. The date value you want to extract the month from. |
3. Example
The first example is in cell B3, it contains: 6/12/2023 which is an Excel date formatted like this mm/dd/yyyy. mm is the month number, dd is the day number, and yyyy is the four digit year in the Excel date.
Formula in cell C3:
The formula in cell C3 returns 6 which represents month "June". If we look at cell B3 we can see that 6 in 6/12/2023 is the month number.
The second example is in cell B4 which contains 3/13/2022.
Formula in cell C4:
The formula in cell C4 returns 3 which corresponds to month "March" which is the third month in a year.
The third example is in cell B5 which contains 10/14/2025.
Formula in cell C5:
The formula in cell C5 returns 10 which corresponds to month "October" which is the tenth month in a year.
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.
4. MONTH Function alternative
The MONTH function returns a number that represents the month in a year based on a given date. The TEXT function allows you to format a string based on a given formatting code which is m, mm, mmm or mmmm. The differences between these codes are:
- m - month number without a leading zero. For example 6
- mm - month number with leading zero if smaller than 10. Based on the example in cell C3: 06
- mmm - the three first letters in the month name, for example, "Jun" which represents "June". Based on the example in cell C3: "Jun"
- mmm - the entire month name. Based on the example in cell C3: "June"
The example in cell C3 shows 6 based on date 6/12/2023, however, the output is different than the MONTH function. The output is a text string in contrast to the MONTH function which returns a number.
Formula in cell C3:
The formula in cell C3 returns "3", the double quotes represent that the output being a text string.
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".
5. Return month name instead of a number
5.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.
5.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".
5.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.
6. 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}.
7. 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.
7.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
7.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B3 converted to hard-coded value using the F9 key. The MONTH function requires valid Excel dates which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
7.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
'MONTH' function examples
Table of Contents Automate net asset value (NAV) calculation on your stock portfolio Calculate your stock portfolio performance with Net […]
Table of Contents Count cells containing text from list Count entries based on date and time Count cells with text […]
This article describes how to count unique distinct values. What are unique distinct values? They are all values but duplicates are […]
Functions in 'Date and Time' category
The MONTH function function is one of 22 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