Please Note: This article is written for users of the following Microsoft Excel versions: 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021. 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: Forcing Dates Forward.

Forcing Dates Forward

Written by Allen Wyatt (last updated April 16, 2022)
This tip applies to Excel 2007, 2010, 2013, 2016, 2019, Excel in Microsoft 365, and 2021


1

Roger is keeping track of invoices in an Excel worksheet. All of the invoices need to be submitted with a due date for the 28th of the month, and Roger wondered if there was a way to force a date to always "jump forward" to the next instance of the 28th.

The cleanest way to force dates forward is to create a formula that will examine a date in a cell and then force that date to the next desired date, such as the 28th. The following formula is a good one to start with:

=IF(DAY(A1)>28,DATE(YEAR(A1),MONTH(A1)+1,28),
DATE(YEAR(A1),MONTH(A1),28))

Remember that this is a single formula; it is entered into a single cell. This formula examines the date in cell A1. If the DAY value of the date is greater than 28, then the formula constructs and returns a date that is equal to the 28th of the next following. If it is less than or equal to 28, then the 28th of the current month is returned.

There is an even shorter way to render an acceptable formula, however—one that entirely gets rid of the IF function:

=DATE(YEAR(A1),MONTH(A1)+(DAY(A1)>28),28)

This uses the current year as the year, and the day is always 28. The month uses a Boolean calculation. If the day is greater than 28, then (Day(A1)>28) will be TRUE and will calculate as a 1, thereby adding 1 to the current month. If it is less than or equal to 28 it will be FALSE and calculate as a 0, just calculating the current month.

If you don't want to be "strict" giving some people only a day (4/27/2012 will give a due date of 4/28/2012), you could plan on giving them at least a week with the formula:

=DATE(YEAR(A1),MONTH(A1)+(DAY(A1)>21),28)

This would give the 28th of the current month for the 1st thru 21st, but for later dates it will jump to the 28th of the following month.

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

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

Printing without Headings

The writer uses headline styles to create a story outline. He does not want to see the headlines when he prints the ...

Discover More

Hiding Graphics

Do you need a printout where graphics can be turned on and off? This tip provides some concrete ways you can get just ...

Discover More

Using Alternating Styles

Alternating styles can come in handy when you have to switch between one type of paragraph and another, automatically, as ...

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

Converting Time Notation to Decimal Notation

Want to convert an elapsed time, such as 8:37, to a decimal time, such as 8.62? If you know how Excel stores times ...

Discover More

End-of-Month Calculations

Don't want to use the EOMONTH function to figure out the end of a given month? Here are some other ideas for discovering ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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}] (all 7 characters, in the sequence shown) 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 two more than 7?

2022-04-17 08:52:03

Beepee

Hi. That is a super snippet. Written just for me? :) Thank you.
I am a beginner at VBA, learnt my original 'programming' skills with ZX Spectum BASIC and have not done much since, until I retired. Used spreadsheets a lot but very little experience of macros.
Anyway, I started with VBA a few months ago and tried to use similar techniques - not always very successful. However, I needed a date calculation for my Gardening Calendar year which goes 1 Oct 2017 to 30 Sep. 2018 (cos that is when I created the sowing/planting/harvesting calendar).
To create a list of jobs that need doing in the next 7-8 days I actually created a procedure that broke down 'todays' date into year/month/day; used DateAdd() to add eight days; used an IF...Then -- to add 1 to the year if the month was 1 - 9 and then reconstructed the date. It worked!!!!! Only 20+ lines of code (including declarations!!) :)

But from your line of code I tweaked it to this: =DATE(YEAR(C2) +(MONTH(I4)<10),MONTH(I4),(DAY(I4)+8)) ...
and that does exactly the same job.
Brilliant -- thanks again and please; keep them coming


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.

Newest Tips
Subscribe

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

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.