How Do I Format Dates and Numbers in a Microsoft Word Mail Merge?

Numbers and dates can be problematic in a Microsoft Word Mail Merge, especially when the data source is an Excel workbook. Some issues are more easily solved than others. Numbers without decimal values, such as a five-digit ZIP Code or an integer count, can be converted to text values in Excel. However, to avoid problems with dates and numbers in decimals, you need to insert formatting codes in these merge fields to format these values correctly in the documents produced.

Merging Integer Numbers

Formatting integers is best performed before importing the source data into Word. This section discusses using Excel.

Step

Open the Excel data source workbook and, if there are multiple sheets, click on the tab of the worksheet containing the source data for the Mail Merge.

Source data for a Word Mail Merge with text, integer, percentage, currency and date data.
credit: Ron Price
Format integer values as text to avoid merge issues.
credit: Ron Price

Step

Select a column containing integer values. Right-click the selected cells and choose Format Cells from the pop-up menu to display the Format Cells dialog box. Click on the Text selection in the Category list. Click OK to apply the format change. The data in the selected cells is now in text format.

Merging Numbers with Decimal Values

For decimals, you can easily format the number directly in Word.

Step

To format the number of decimal places in a numeric field, such as currency, percentages or any number with decimal values, add formatting codes to the merge field. Open the Mail Merge document (letter, email, etc.) to display its merge fields, which appear as <>, such as <>, for example.

A sample Merge letter showing the embedded merge fields.
credit: Ron Price
Choose Toggle Field Codes to display the details of the merge field.
credit: Ron Price

Step

The merge field <> merges a currency amount from the data source. Right-click on the <>merge field and choose Toggle Field Codes from its pop-up menu to display its formatting, if any.

Examples of merge field codes with no formatting applied.
credit: Ron Price

Step

The <> merge field should now show { MERGEFIELD "Amount" }. No formatting is included for this field. To display the merged data as a currency field, enter "# $,#.00" after the field name in the merge field. The merge field should now contain {MERGEFIELD "Amount" # $,#.00}, where:

Step

  • # - Indicates that formatting follows.
  • $ - Designates a character to be displayed at the front of the field.
  • , (comma) - Indicates commas are to be inserted, if applicable, in a numeric value.
  • # (number sign) - Indicates the number of fixed digits to display.
  • .00 - Indicates that a decimal value of two places (in this case) is to be displayed. A number without decimals displays with zeros after the decimal.

Merging Percentages

Like any number calculated by a formula in Excel, the raw values may not be limited to only two fixed decimal places, regardless of what displays in the cell. As shown in the previous step, the length of a number, especially any decimals, can be set to a fixed number of positions.

Actions in Formatting Codes

The merge field formatting code to display a percentage with two decimal places and a percent sign
credit: Ron Price

In some cases, it is necessary to merge a data field before it can be acted upon. The "Pct" field in the example is a case in point. To have this data appear in the merged document as a two-decimal percentage with at least one significant digit and a percent sign, requires two actions.

Step

Replace the existing MERGEFIELD statement with the innermost action of the new statement MERGEFIELD "Pct". This statement clause retrieves the data from the data source and makes it available to the remainder of the formatting code. After entering the innermost clause, use the CTRL-F9 keys to enclose the statement in braces.

Step

Enter an equal sign ("=") before the statement entered in Step 1. This tells the Merge function that the statement includes an operator. Next enter the remainder of the formatting code, *100 # “#0.00%”, immediately behind the rightmost brace of the inner statement. This clause multiplies the merge value by 100 (to shift the decimal place), formats the value as a two decimal percentage and displays the percent sign. At this point, the merge field should be ={ MERGEFIELD “Pct”}*100 # “#0.00%”. Use CTRL-F9 to enclose the entire statement in braces and active it.

Merging Dates

To merge a date from Excel in the format of M/d/y, for example 6/15/2015, you don't need special formatting. This date format merges as is just fine. However, if you wish to display the date in any other format, such as June 15, 2015, some formatting codes are needed.

To merge a date field and display it as day, month, year, the formatting code is "\@ "MMMM d, yyyy", where "\@" indicates a date format and " MMMM d yyyy" indicates the month in text, the day with no leading zero and the year as a four-digit number

The results of a Mail Merge showing formatted date, currency and percentage fields.
credit: Ron Price