Written by Allen Wyatt (last updated September 6, 2025)
This tip applies to Word 97, 2000, 2002, and 2003
Volker is having a problem comparing dates in a merge field. His database contains a Birthdate field, which (obviously) contains a birth date for each person in the database. As he merges each record, he wants to compare the Birthdate field to a reference date, and then take some action based on the result. The logic he is attempting to use looks like this:
{IF {MERGEFIELD Birthdate} > "02/26/1981" "Under 30" "Over 30"}
The problem is that the comparison doesn't work properly; it doesn't return consistent results. One possible solution is to use a format switch in the merge field, in the following manner:
{IF {MERGEFIELD Birthdate\@"MM/DD/YYYY"} > "02/26/1981" "Under 30" "Over 30"}
This puts the incoming information into a comparable format. The results you get from this approach may depend, however, on characteristics of the data source, independent of Word. You could also try putting the dates into a year-first format, such as the following:
{IF {MERGEFIELD Birthdate\@"YYYY/MM/DD"} > "2011/02/26" "Under 30" "Over 30"}
If the comparison still yields inconsistent results, then the only solution may be to do a mathematical conversion on the date (actually, on both Birthdate and the reference date) so that you have an actual numeric comparison. You can do this by converting the date into a Julian value, which requires a very complex merge field, like the one shown here:
{IF {QUOTE {SET a{=INT((14-{MERGEFIELD BIRTHDATE \@ M})/12)}} {SET b{={MERGEFIELD BIRTHDATE \@ yyyy}+4800-a}} {SET c{={MERGEFIELD BIRTHDATE \@ M}+12*a-3}} {SET d{MERGEFIELD BIRTHDATE \@ d}} {SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045}} {jd \#,0}} > 2,443,056 "over 30" "under30"}
Such an approach may look intimidating, but is just the brute-force method necessary for some instances.
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (356) 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: Proper Comparisons for Dates in Merge Fields.
Discover the Power of Microsoft Office This beginner-friendly guide reveals the expert tips and strategies you need to skyrocket your productivity and use Office 365 like a pro. Mastering software like Word, Excel, and PowerPoint is essential to be more efficient and advance your career. Simple lessons guide you through every step, providing the knowledge you need to get started. Check out Microsoft Office 365 For Beginners today!
When creating a mail merge document, you use merge fields to indicate where the information from each record of your data ...
Discover MoreWhen you create a mail merge document, you attach it to a data source that is the basis for the information to be merged ...
Discover MoreThe security features introduced in Word 2003 resulted in a change in the dialog boxes you see when opening mail-merge ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
There are currently no comments for this tip. (Be the first to leave your comment—just use the simple form above!)
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