Search code examples
ms-wordword-fieldfieldcodes

Display date difference in MS Word field


I have an CV and would like to automatically update my age when opening. So, what formula should I insert in a MS Word field?

Something like:

{= {DATE} - {"01/01/1983"} }


Solution

  • This is one of the better sites for working with Word field codes - http://www.addbalance.com/usersguide/fields.htm - and there are examples there on how to create +/- dates.

    Here's how you would calculate based of a birth month of January and birth year of 1983.

    {IF{DATE\@"MM"} >= 01 { = {DATE\@"YYYY"} – 1983 \#"00"} { = {DATE\@"YYYY"} – 1984 \#"00"}}

    Note that in the case of the month of January, this IF statement will always be true and give you =YEAR-1983. You can use another nested IF statement to check on the day to further get more accurate.