Microsoft KB Archive/89532

= WD: How to Use Dates as Mail Merge Selection Criteria =

Article ID: 89532

Article Last Modified on 8/15/2007

-

APPLIES TO


 * Microsoft Word 2.0 Standard Edition
 * Microsoft Word 2.0a
 * Microsoft Office Word 2003
 * Microsoft Word 2.0c
 * Microsoft Word 6.0 Standard Edition
 * Microsoft Word 6.0a
 * Microsoft Word 6.0c
 * Microsoft Word 95 Standard Edition
 * Microsoft Word 95a
 * Microsoft Word 6.0 for Macintosh
 * Microsoft Word 6.01 for Macintosh
 * Microsoft Word 6.01 for Macintosh
 * Microsoft Word 98 for Macintosh

-



This article was previously published under Q89532





SUMMARY
In Microsoft Word, you can perform a selective mail merge based on a list of dates. For example, you can merge records based on such criteria as a group of months, days of months, years or combinations of all three. For example, you can perform a selective mail merge based on a list of names and birth dates.

In addition, you can instruct Word to change the date format of data in the merged document.



MORE INFORMATION
To use the selective merge function:

 Set up the data document. For example:

FRIENDS,BIRTHDATE

Karan Khanna, 10-5-1940

Jon Morris, 6/1/1926

Megan Sherman, 5/26/1907

NOTE: You can use either forward slashes or dashes in the dates. If your data document is formatted as a table, you can also spell out the date (for example, &quot;June 1, 1926&quot;).

NOTE: The example companies, organizations, products, people, and events depicted herein are fictitious. No association with any real company, organization, product, person, or event is intended or should be inferred. Set up the main document:  {if {MERGEFIELD Birthdate \@ &quot;MMMM&quot;}=&quot;October&quot; &quot;{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ &quot;MMMM d, yyyy&quot;}&quot;}

This example merges records for people born in October. The Birthdate field is formatted as &quot;October 5, 1940&quot;, regardless of the data format of the data document (October 5, 1940, or 10/5/1940, or 10/5/40). {if {MERGEFIELD Birthdate \@ &quot;MM&quot;}=&quot;10&quot; &quot;{MERGEFIELD Friends} {MERGEFIELD Birthdate}&quot;}

This example works the same as example a, except that the Birthdate prints exactly as it appears in the data document. {if {MERGEFIELD Birthdate \@ &quot;yy&quot;}=&quot;40&quot; &quot;{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ &quot;MM/dd/yy&quot;}&quot;}

This example merges records for people born in 1940. The Birthdate field is formatted as &quot;10/5/40.&quot; {if {MERGEFIELD Birthdate \@ &quot; yyyy&quot;}=&quot;1940&quot; &quot;{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ &quot;d-MMM-yy&quot;}&quot;}

Same result as example 3 above, except that the Birthdate prints in &quot;5-October-40&quot; format.</li> {if {MERGEFIELD Birthdate \@ &quot;MMMM d, yyyy&quot;}=&quot;October 5, 1940&quot; &quot;{MERGEFIELD Friends} {MERGEFIELD Birthdate}&quot;} Merges only the records of people born on October 5, 1940.</li></ol> </li></ol>

NOTE: To enter the field brackets ({}), choose Field from the Insert menu (or press CTRL+F9 in Windows or COMMAND+F9 in Macintosh).

These examples do not illustrate all possible selective merge combinations or date formats. To view all possible DATE field switches, choose field from the Insert menu. Under Categories, select Date And Time, under Field Names, select Date, and then click Options. All the possible date switch combinations appear in the Instructions box.

It is not possible to do a selective print merge using less than or greater than statements based on dates because Word interprets the dates as text. The dates in Word do not have a numerical value that can be compared.

For example this will NOT work:

{ if {MERGEFIELD mydate \@ &quot;M/d/yy&quot;} > &quot;4/15/97 &quot;true&quot; &quot;false&quot; }

<div class="references_section">