Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, and 2013. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Calculating a Future Date.

Calculating a Future Date

by Allen Wyatt
(last updated October 11, 2017)

3

If you are creating a macro to do some processing on a document, you may have a need to calculate a date at some point in the future. Using the VBA DateAdd function, this is quite easy. The function has the following syntax:

DateAdd(interval, number, startdate)

The original date that you begin with (typically today's date) is specified by the startdate argument. The interval argument indicates what you want to add to the startdate. For instance, if you want to add days, then interval would be the letter d. (This interval needs to be enclosed within quotes.) There are many different intervals you can specify:

Interval Meaning
d Day
ww Week
m Month
q Quarter
yyyy Year
y Day of year
w Weekday
h Hour
n Minute
s Second

Finally, the number argument specifies how many intervals you want to add to the date.

As an example, let's suppose you wanted to know the date that was 90 days in the future. You could use the following:

dFutureDate = DateAdd("d", 90, Date)

When executed, dFutureDate contains the date that is 90 days after today.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (12916) applies to Microsoft Word 2007, 2010, and 2013. You can find a version of this tip for the older menu interface of Word here: Calculating a Future Date.

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

Determining the Length of a String

Macros are great for working with strings, and one of the most commonly used string functions is Len. This tip explains how ...

Discover More

Breaking Links in Lots of Documents

Breaking document links can be a tedious chore, especially if there are lots of links and lots of documents. This tip ...

Discover More

Adding Buttons to Your Worksheet

You can easily add a button to your worksheet that will allow you to run various macros. This tip shows how easy it is.

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 WordTips (ribbon)

Determining a Random Value

If you need to determine a random value in a macro, you can do so using the Rnd function. This tip presents the syntax and ...

Discover More

Deleting a Macro

ScreenTips can appear with or without shortcut keys displayed in them. Here's how to control whether they appear or not.

Discover More

Displaying the User Name in the Status Bar or Title Bar

Sometimes it can come in handy to know who the current computer user is, as far as Word is concerned. This tip presents ways ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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}] 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 4?

2016-01-12 17:01:23

David

How do you insert this macro into a Word document? I have been using a Date Picker Context Control box, for a current date, but I need to add a block for a future date. Can you please help me?

Thanks,


2015-09-10 11:28:30

ken

Private Sub Document_Open()
Dim myDate As Date
Dim myRng As Range
'Set the starting date with the value of a field
Set myRng = ActiveDocument.Fields(1).Result
myDate = myRng
myRng = DateAdd("d", 1, Date)

End Sub


2015-07-24 12:50:02

Joe Frasca

Thanks for posting this tip. It seems clear and I will be trying it.


This Site

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

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, 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.