Written by Allen Wyatt (last updated October 26, 2023)
This tip applies to Word 97, 2000, 2002, and 2003
Aidan asked if it is possible to calculate dates using fields. Seems he wants a date that is two weeks in the future and thought there must be an easy way to calculate such a future date using fields. Unfortunately, there is no easy way. While Word allows you to do simple calculations using numeric values in fields, it does not allow you to perform such calculations using dates instead of numbers.
You can, however, pull dates apart into their intrinsic portions (months, days, and years), and then do your calculations, but this introduces whole new problems. All of a sudden you need to be concerned with what happens when you "roll" past the end of a month or year. The math involved in doing such a calculation is not trivial. As an example, consider the following compound field:
{QUOTE "{SET Delay "14"}{SET "DaysInMonth" {IF {DATE \@ "MM"} <> 2 {=ROUND(30.575*{DATE \@ "MM"},0)-ROUND(30.575*{= {DATE \@ "MM"} —1},0)}{IF {=MOD({DATE \@ "yy"|, 4)} > 0 "28" "29"}}}{SET "NextMonth" {IF {DATE \@ "MM"} = 12 "1/97" "{= {DATE \@ "MM"} + 1}/97}}{IF {= {REF Delay} + {DATE \@ "dd"}} <= {DaysInMonth} {DATE \@ "MMMM {= {REF Delay} + {DATE \@ "dd"}}, yyyy"}{QUOTE "{NextMonth \@ "MMMM"} {= {REF Delay} + {DATE \@ "dd"} — {DaysInMonth}}, {IF {DATE \@ "MM"} <> 12 {DATE \@ "yyyy"}{DATE \@ "{= 1 + {DATE \@ "yyyy"} \# "xxxx"}" }}}}"}
This will return the date in two weeks time (specified in the first line where the Delay value is set. The drawback, of course, is the compound nature of the field—there are over 30 different fields just within this compound field! Even this implementation, as formidable as it looks, will not handle leap years correctly in all instances. (It won't handle leap years correctly in century years divisible by 400.)
Is there an easy way to calculate future dates? Yes, there is—simply use macros. With just a couple of simple instructions you can make short work out of otherwise difficult date calculations. The way this is done was covered in an earlier WordTips; you can also find information at the following Word MVP page:
https://word.mvps.org/FAQs/MacrosVBA/DateOfPrevMonth.htm
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1579) applies to Microsoft Word 97, 2000, 2002, and 2003. You can find a version of this tip for the ribbon interface of Word (Word 2007 and later) here: Calculating Dates with Fields.
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!
If you need to control exactly where text will appear on the page or relative to other text, you need to know about the ...
Discover MoreOne of the most commonly used fields is the DATE field. You can specify how the DATE field displays the current date by ...
Discover MoreYou can create a special header and footer page numbering scheme by using nested fields. This tip shows an example of how ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2020-07-09 19:29:40
Ben Sims
I entered that equation into Word, then I tried to Ctrl+F9 match all of the field brackets. Unfortunately, it looks like I have one too many "{" facing brackets (the loner is just before "...SET "DaysInMonth"..." near the beginning. My best guess is that it's "}" facing pair should be before the final double quote (") at the end, but I can't get it to work. Has anyone else had an issue with this?
Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2025 Sharon Parq Associates, Inc.
Comments