Microsoft KB Archive/214214

= WD2000: How to Use Dates As a Mail Merge Selection =

Article ID: 214214

Article Last Modified on 12/6/2000

-

APPLIES TO


 * Microsoft Word 2000 Standard Edition

-



This article was previously published under Q214214





SUMMARY
You can perform a selective mail merge based on a list of dates. You can merge records based on criteria such 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 Microsoft Word to change the date format of data in the merged document.



MORE INFORMATION
To use the selective merge function, follow these steps.  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 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, June 1, 1926). Also, if you are using a tab- or comma-delimited text file as a data source, be sure to follow the conventions for formatting these types of files. For more information, see the "References" section later in this article. 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. Create the formula you want, based on the examples below.

NOTE: Using the IF field to set up a selective merge generates blank pages because the Merge command creates a document for each record it reads, whether the record meets the criteria in the IF statement or not.  {IF {MERGEFIELD Birthdate \@ "MMMM"}="October" "{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ "MMMM d, yyyy"}"}

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

This example works the same as example a, except the birthdate prints exactly as it appears in the data document. {IF {MERGEFIELD Birthdate \@ "yy"}="40" "{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ "MM/dd/yy"}"}

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

This example produces the same result as example c above, except the birthdate is formatted as 5-October-40.</li> {IF {MERGEFIELD Birthdate \@ "MMMM d, yyyy"}="October 5, 1940" "{MERGEFIELD Friends} {MERGEFIELD Birthdate}"}

This example merges only the records of people born on October 5, 1940.</li></ol> </li></ol>

NOTE: To enter the field brackets ({}), select Field on the Insert menu (or press CTRL+F9).

The examples above do not illustrate all possible selective merge combinations or date formats. To view the possible DATE field switches, follow these steps. <ol> On the Insert menu, select Field.</li> In the Field dialog box, follow these steps: <ol style="list-style-type: lower-alpha;"> Under Categories, select Date and Time.</li> Under Field names, click Date, and then click Options to see the available DATE field switches.</li></ol> </li></ol>

NOTE: It is not possible to set up a selective print merge that combines less-than or greater-than statements with dates, because Word interprets the dates as text. The dates do not have a numeric value that can be compared.

For example, the following formula does not work:

{IF {MERGEFIELD mydate \@ "M/d/yy"} > "4/15/97" "true" "false" }

<div class="references_section">