Being able to apply functions and formats to dates is an excellent feature of Excel, and it can make date-related tasks extremely easy. This tutorial will teach us how to get the previous month’s name from a date in Excel.
To do this, first, we will learn how to get the current month’s name, and then the previous month’s name.
1) Get the Current Month’s Name
We will first learn how to get the current month’s name from any date, or today’s date. From there, we will continue to get the previous month’s name.
As you know, there are different formats of cells, such as number, currency, date, time, text, etc. You can check the format of a cell by right-clicking on the cell, and then clicking Format Cells.
If you want to get the current month from a date within a cell, you first need to make sure that the cell is in the date format.
Using the TEXT Function
Step 1: Right-click the cell that contains a date, and click on “Format Cells…”.
Step 2: Select Date under Category, and then click on OK.
If you entered the date in the correct format such as 02/14/2023, the format of the cell can also automatically be determined by Excel as Date.
Step 3: In a new cell, write the following formula:
=TEXT(A1, "mmmm")
In place of A1, you can write any cell name or today’s date with the TODAY function:
=TEXT(TODAY(), "mmmm")
The TEXT function takes the date as an argument and returns the month name, whose format is determined with the “mmmm” argument.
Using Format Cells
The same operation can be performed with the Format Cells dialog box.
Step 1: Right-click on the cell that contains the date, and click on Format Cells.
Step 2: Select Custom under Category. Type “mmmm” in the Type text box, then click on OK.
This will convert the current date into the current month:
2) Get the Previous Month’s Name
Now that we learned how to get the current month’s name, we can easily obtain the previous month’s name.
To achieve this, we will simply subtract the number of days in our date from the date itself, which will take us to the last day of the previous month. From there, we will get the previous month’s name with the TEXT function.
First, we have today’s date:
=TODAY()
We subtract the number of days within today’s date, from today:
=TODAY() – DAY(TODAY())
This gives us the last day of the previous month (cell B3 below). Now, we will obtain the month from this date using the TEXT function:
=TEXT(TODAY() - DAY(TODAY()), "mmmm")
So, the formula to get the previous month’s name is:
=TEXT(TODAY() - DAY(TODAY()), "mmmm")
You can apply this formula to any cell that contains a date, by replacing the TODAY function with the cell name:
=TEXT(A1 - DAY(A1), "mmmm")
Simple, right? Once you get used to the formulas in Excel, everything is possible. In this tutorial, we learned how to get the current month and the previous month from any date. Nice job!