logo
search
Document Editing Problems

How to Use Word Mail Merge to Highlight Dates Within 12 Months

Huda QurayshiHuda Qurayshi Sep 27, 2026 869 views

Question details

The user needs to compare a merged date with today's date in Word Mail Merge and apply conditional formatting (like red text) when the date is less than 12 months away.

How to Highlight Dates Within 12 Months in Word Mail Merge
Product
Word
Device & OS
not provided
Scenario
Setting up a mail merge document that dynamically checks an expiration date against the current date and applies visual highlighting if the deadline is approaching within a year.
Observed behavior
Users often encounter issues where field codes display default formatting, braces are recognized incorrectly, or DATEADD functions yield a 'Bookmark not defined' error.
Before you start

Ensure your data source (like an Excel spreadsheet) is properly connected to your document and that the date column contains valid date formats rather than plain text.

Solution 1Recommended

Use an IF Field with the Charformat Switch

Apply conditional logic directly within your Mail Merge document to evaluate dates and change text formatting dynamically.

To evaluate dates in a mail merge, you must use nested field codes. It is critical that all curly braces are generated using the keyboard shortcut rather than typing them manually, or the condition will fail to execute.

When using the conditional IF field, applying the \* Charformat switch allows you to format the output text based on the formatting applied to the first letter of the field code.

1
Insert Field Code Braces

Place your cursor where you want the conditional text to appear. Press Ctrl+F9 to insert a pair of empty field braces { }. Do not type the braces using your keyboard.

2
Construct the IF Condition

Inside the braces, type your IF statement to compare the merged date field with a date 12 months prior to today. For example: IF { MERGEFIELD form_expiry_detector_1 \@ "yyyy/MM/dd" } < { DATE \@ "yyyy/MM/dd" \* DATEADD -12 } "Date is less than 12 months" "Date is 12 months or more" (Remember to use Ctrl+F9 for every inner pair of braces).

3
Apply Formatting with Charformat

To apply different text colors to the result, append the \* Charformat switch at the end of your IF field. Select the first letter of the word 'IF' and change its font color to red. The output will adopt this color when the condition is met.

4
Preview the Results

Press Alt+F9 to toggle off the field codes, then click 'Preview Results' in the Mail Merge ribbon to verify that the conditional text and colors are displaying correctly based on your source data.

Use an IF Field with the Charformat Switch
Handling DATEADD Errors: If you receive a 'Bookmark not defined' error when using DATEADD, this implies your environment lacks the macro or extension supporting this specific date calculation. In such cases, it is highly recommended to pre-calculate the 12-month expiry condition in a helper column within your Excel data source.
Simplify Your Document Workflow

Easily Manage Mail Merges with WPS Writer

WPS Writer offers a highly intuitive and robust Mail Merge feature. You can effortlessly link data sources, insert fields, and generate customized documents without wrestling with complex field codes. For complex conditional formatting like 12-month date comparisons, WPS integrates seamlessly with WPS Spreadsheet to let you pre-calculate logic easily.

  1. 1. Open Mail Merge: Launch WPS Writer, navigate to the 'References' tab, and click on 'Mail Merge' to activate the toolbar.
  2. 2. Connect Data Source: Click 'Open Data Source' to link your pre-calculated Excel or WPS Spreadsheet containing the highlighted date flags.
  3. 3. Insert Merge Fields: Place your cursor in the document and click 'Insert Merge Field' to add your required data points perfectly formatted.
  4. 4. Merge to Document: Click 'Merge to New Document' to generate your final highlighted files instantly.
Seamlessly compatible with Microsoft Word (.docx) formats and mail merge structures.Intuitive Mail Merge wizard makes connecting data sources faster and easier.Free, lightweight, and user-friendly interface with zero learning curve.Built-in spreadsheet integration allows easy pre-calculation of conditional date fields.
microsoft office alternative - wps office

Frequently Asked Questions

Why is my Mail Merge showing field codes instead of the actual data?

Your document is likely displaying field codes instead of field values. You can easily toggle between the two views by pressing Alt+F9 on your keyboard.

Why aren't my curly braces working in the conditional IF field?

Field code braces cannot be typed manually using the bracket keys on your keyboard. You must insert them by pressing Ctrl+F9 so Word recognizes them as programmable fields.

What is the easiest way to avoid complex date calculations in Mail Merge?

The most reliable workaround is to calculate the expiration dates or differences in your Excel spreadsheet source file using standard formulas (like EDATE or DATEDIF). You can then create a column that outputs 'Red' or 'Within 12 Months' and merge that directly into your document.