WD: How to Use Dates as Mail Merge Selection Criteria

Last reviewed: February 2, 1998
Article ID: Q89532
The information in this article applies to:
  • Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word 98 Macintosh Edition

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

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:

  1. Set up the data document. For example:

          FRIENDS,BIRTHDATE
          Raquel Tejeda,10-5-1940
          Norma Jean Baker,6/1/1926
          Marion Michael Morrison,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, "June 1, 1926").

  2. Set up the main document:

    a. {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 as "October 5, 1940", regardless
          of the data format of the data document (October 5, 1940, or
          10/5/1940, or 10/5/40).
    

    b. {if {MERGEFIELD Birthdate \@ "MM"}="10" "{MERGEFIELD Friends}

          {MERGEFIELD Birthdate}"}
    

          This example works the same as example a, except that the Birthdate
          prints exactly as it appears in the data document.
    

    c. {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."
    

    d. {if {MERGEFIELD Birthdate \@ " yyyy"}="1940"

          "{MERGEFIELD Friends} {MERGEFIELD Birthdate \@ "d-MMM-yy"}"}
    

          Same result as example 3 above, except that the Birthdate prints in
          "5-October-40" format.
    

    e. {if {MERGEFIELD Birthdate \@ "MMMM d, yyyy"}="October 5, 1940"

          "{MERGEFIELD Friends} {MERGEFIELD Birthdate}"}
    

          Merges only the records of people born on October 5, 1940.
    

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 \@ "M/d/yy"} > "4/15/97 "true" "false" }

For information on working with dates, please see the following articles in the Microsoft Knowledge Base:

     ARTICLE ID: Q122842
     TITLE: WD: How to Perform Calculations with Dates and Times

     ARTICLE ID: Q105537
     TITLE: WD: How to Determine the Number of Days Between Two Dates

REFERENCES

"Microsoft Word for Windows User's Guide," version 2.0, pages 609-656, 751


Additional query words: conditional pmh
Keywords : kbfield kbmerge macword winword winword2 word6 word7 word8 word95 word97 word98 kbualink97
Version : WINDOWS:2.0,2.0a,2.0a- CD,2.0b,2.0c,6.0,6.0a,6.0c,7.0,7.0a,97;MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 2, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.