Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. If you are using an earlier version (Excel 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Excel, click here: Determining Month Names for a Range of Dates.

# Determining Month Names for a Range of Dates

by Allen Wyatt
(last updated April 21, 2018)

Anita has a worksheet with over 10,000 rows. Each row represents an individual contract. Each contract has a start date (column A) and an end date (column B). She needs a way to list in columns C, D, E, etc. the individual months covered by the contract. For instance, if column A contains 01 July 2017 and column B contains 30 September 2017, she needs column C to contain Jul 17, column D to contain Aug 17, and column E to contain Sep 17. Whatever formulas are used need to accommodate contract lengths that may be quite different.

There are several ways to go about such a task. It is possible to use some intermediate columns that specify things like the starting month and the number of months of each contract, but it turns out that such intermediate columns are not necessary. For instance, assuming that your contracts start in row 2, you could place the following formula in cell C2:

```=TEXT(A2,"mmm yy")
```

Then, beginning in cell D2 you could place this formula:

```=IF(DATE(YEAR(\$A2),MONTH(\$A2)+COLUMNS(\$D2:D2),
DAY(\$A2))>\$B2,"",TEXT(DATE(YEAR(\$A2),MONTH(\$A2)
+COLUMNS(\$D2:D2),DAY(\$A2)),"mmm yy"))
```

This is one formula, and it uses the position of the cells containing the formula, along with the contract starting date, to calculate, basically, the month of offset from that starting month. The formula can be copied toward the right (columns E, F, G, etc.) for as far as necessary to display all the months and years.

The one drawback to the formula is that if the contract ending date is earlier in the month than the contract starting date, then the last month is not displayed. Thus, if the contract starts on 12 June 2017 and it ends on 05 February 2018, then the last month (February) will not be displayed by the formula. You could, instead, use the following formula in cell C2 and copy it to the right as far as necessary:

```=IF(DATE(YEAR(\$A2),MONTH(\$A2)+COLUMN()-2,0)
>DATE(YEAR(\$A2),MONTH(\$B2)+1,0),"",TEXT(DATE
(YEAR(\$A2),MONTH(\$A2)+COLUMN()-2,0),"mmm yy"))
```

This formula also relies on the columns in which it resides, using them to calculate an offset from the contract start date. The formula will work just fine, regardless of the relationship between the contract start and end dates.

If you don't want to rely on column positioning, there is another approach you can take. Place the following formula in cell C2:

```=(A2)
```

Then, in cell D2 place the following formula:

```=IF(\$B2>C2,EOMONTH(C2,1),"")
```

Copy the formula in D2 to the right as many cells as necessary, and then format all those cells (including C2 and D2) as dates that display only the month and year. The formula will look at B2 (the contract ending date) to see if it is larger than C2. If it is, then the formula returns the serial number of the last day of the next month in series. If it is not, then a blank ("") is returned.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (12584) applies to Microsoft Excel 2007, 2010, 2013, 2016, 2019, and Excel in Office 365. You can find a version of this tip for the older menu interface of Excel here: Determining Month Names for a Range of Dates.

##### Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He is president of Sharon Parq Associates, a computer and publishing services company. ...

##### MORE FROM ALLEN

Unwanted Page Breaks in Cross-References

You can use fields to cross-reference different text in a document. If you get unwanted results from the ...

Discover More

Understanding Precedence

Formulas created in a macro have a specific order in which operations are performed. This is known as precedence, as ...

Discover More

Pushing Dates Into Last Month

Excel is great when it comes to working with dates and times. You can even do math on dates. One such easy manipulation ...

Discover More

Comprehensive VBA Guide Visual Basic for Applications (VBA) is the language used for writing macros in all Office programs. This complete guide shows both professionals and novices how to master VBA in order to customize the entire Office suite for their needs. Check out Mastering VBA for Office 2010 today!

##### More ExcelTips (ribbon)

Calculating a Date Five Days before the First Business Day

Excel allows you to perform all sorts of calculations using dates. A good example of this is using a formula to figure ...

Discover More

Counting Dates in a Range

Excel makes working with a list of dates relatively easy. If you have a list of dates, you may need to know how many of ...

Discover More

Using a Two-Character Day of the Week in a Date Format

Excel provides quite a bit of flexibility in how you can format dates. Even so, some dates simply cannot be formatted ...

Discover More
##### Subscribe

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. Youâ€™ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 7 + 4?

2020-07-27 00:14:52

Sam

Hello, thank you for the helpful tips!
I am having a problem when my start date and end date span different years. The formula you suggested (pasted below) works perfect as long as all dates are within a given year. If my end date goes into the next year this formula only recognizes the month, and does not wrap into the next year. Suggestions? I'm using Office Professional Plus 2019.

=IF(DATE(YEAR(\$A2),MONTH(\$A2)+COLUMN()-2,0)
>DATE(YEAR(\$A2),MONTH(\$B2)+1,0),"",TEXT(DATE
(YEAR(\$A2),MONTH(\$A2)+COLUMN()-2,0),"mmm yy"))

2020-05-03 18:22:01

Peter Atherton

Marc
Picture was poor, 5this should be better

(see Figure 1 below)

Figure 1. Formulas & PasteOptions

2020-05-03 16:13:48

Peter Atherton

Marc
There are severaval way to do this.
Enter a date in say A2 then drag it down. The dates will increment by one day. However, at the end of the range is a little dropdown icon. Click this and you will see a range of options, increment by Days, Weeks, Months, Year select the one you want and it is done.

Here is a formula the does the same:= in A3 enter =DATE(YEAR(A2),MONTH(A2)+1,17)

If you want the formula to stop after the date in say B1 and the start date is in B2, enter the formula in B3 and copy down:=
=IF(DATE(YEAR(B2),MONTH(B2)+1,17)>\$B\$1,"",DATE(YEAR(B2),MONTH(B2)+1,17))

(see Figure 1 below)

Figure 1. Various Date Series

2020-05-02 19:59:51

Marc

Is it possible to return the range of dates in a single column?

##### This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.