How to calculate date in Word to add into Mail Merge?

1.9k views Asked by At

Is it possible to calculate a date and then insert into a MS Word document? E.g. An excel sheet contains a date column (lets say 10-Jan-2020). I am using the same date to be inserted through mail merge and also I want to use the same date again with extension of 5 years (i.e. 10-Jan-2025) to be inserted into same document. Is it possible? if yes, how to do that? Please guide.

P.S. I don't have provision to make an other field into excel sheet.

1

There are 1 answers

0
macropod On

You could use a field coded as:

{QUOTE↵
{SET yy{={MERGEFIELD DATE \@ yyyy}+5}}↵
{SET mm{MERGEFIELD DATE \@ MM}}↵
{SET dd{={MERGEFIELD DATE \@ d}-({DATE \@ d}>28)*({DATE \@ M}=2)*((MOD(yy,4)>0)+(MOD(yy,400)>0)-(MOD(yy,100)>0))}}↵
"{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac or, if you’re using a laptop, you might need to use Ctrl-Fn-F9); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field constructions are all required. Instead of the ↵ symbols, you should use real line breaks.

Rather than trying to re-type the above, you could use the Convert Text Representations of Fields to Working Fields macro in the Mailmerge Tips and Tricks thread at:

https://www.msofficeforums.com/mail-merge/21803-mailmerge-tips-tricks.html.

Alternatively, you could copy the field code directly from the Calculate a day, date, month and year, using n years delay example in my Microsoft Word Date Calculation Tutorial, at:

https://www.msofficeforums.com/word/38719-microsoft-word-date-calculation-tutorial.html

or:

http://www.gmayor.com/downloads.htm#Third_party

Then edit the field code as per the above.