Thread: [Solved] Age Calculation
View Single Post
 
Old 10-31-2012, 03:35 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, copy the existing field code into your mailmerge main document, toggle the filed code display 'on' via Alt-F9, then make the following edits:

1. Just after the 'QUOTE' expressiion, press Ctrl-F9 to create a new field with a pair of field braces, thus:
{QUOTE { }{IF ...
2. Within the new field braces type 'SET Birthdate', thus:
{QUOTE {SET Birthdate }{IF ...
3. After 'Birthdate', press Ctrl-F9 to create a new field with a pair of field braces, thus:
{QUOTE {SET Birthdate { }}{IF ...
(note the space after 'Birthdate').
4. Within the new field braces type 'MERGEFIELD MAT_Child_1_DOB', thus:
{QUOTE {SET Birthdate {MERGEFIELD MAT_Child_1_DOB}}{IF ...

Your field code should now look like:
{QUOTE {SET Birthdate {MERGEFIELD MAT_Child_1_DOB}}{IF{=Birthdate \@ YYYYMMDD}= 0 "" "{Set Years{=INT(({DATE \@ YYYYMMDD}-{REF Birthdate \@ YYYYMMDD})/10000)}}{Years} Year{IF{Years}= 1 "" s} }"}

5. Press Alt-F9 to toggle the field code display.

Your mailmerge age calculation is now ready to run.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote