WD2000: How to Use Dates As a Mail Merge Selection (214214)



The information in this article applies to:

  • Microsoft Word 2000

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.
  1. 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.

  2. 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.
    1. {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).
    2. {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.
    3. {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.
    4. {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.
    5. {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.
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.
  1. On the Insert menu, select Field.
  2. In the Field dialog box, follow these steps:
    1. Under Categories, select Date and Time.
    2. Under Field names, click Date, and then click Options to see the available DATE field switches.
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" }

REFERENCES

For more information about formatting date fields, click Microsoft Word Help on the Help menu, type field codes: date field in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

For more information about using a tab- or comma-delimited text as a data source, click Microsoft Word Help on the Help menu, type use a tab- or comma-delimited text file as a data source in the Office Assistant or the Answer Wizard, and then click Search to view the topic.

Modification Type:MajorLast Reviewed:12/6/2000
Keywords:kbfield kbhowto kbinfo kbmerge KB214214