Automatic Age Calculation in Word Document

Copper Contributor

Hi everyone, 

I am writing a Business Plan and I'd like to insert a person's age automatically as I don't know when this document will be needed. Therefore I just want to make the document "smarter" by automating some things hence don't worry about updating it in x years when it is needed. 

 

After a couple of hours of research now and endless attempts to do so I reached the end of my patience. The last thing I did was working with fields and inserting formulars I found online. 

Here is what I have written in a field (by pressing CTRL+F9): {=INT ({DATE\@"yyyy"} + {DATE\@"M"}/12 + {DATE\@"d"}/365.25-1989-8/12-25/365.25)}

Here you can see that I want to calculate the age today of this person (DOB: 25 August 1989).

 

Any help here is greatly appreciated. Not sure if it is better to work with fields here or macros. Happy for every solution which is "easy" to implement :)

1 Reply

@Andreas1991

Date calculations in Word fields are incredibly complex. Excel is much simpler for this.

Calculated Dates in Microsoft Word using Fields or vba

 

Download Word MVP Paul Edstein's Microsoft Word Date Calculation Tutorial .

It is a document with multiple Date calculation fields that you can copy and adapt in your templates.

Read the introductory remarks.

An alternative download location is Downloads from Graham Mayor, MVP under third-party downloads.

 

You could also use the Insert Future (or Past) Date Add-in by Graham Mayor, MVP 

 

The following is from page 11 of the tutorial document. Do NOT try to type this field. Copy it from the tutorial and modify to suit.

 

"The following field uses an ASK field to get your birth date, from which to calculate one’s age:

If your Date of Birth was 1 January 1901, then your age is 123 Years, 5 Months and 3 Days.

 

{QUOTE
{ASK BirthDate "What is the Birthdate?"}
{SET by {BirthDate \@ yyyy}}
{SET bm {BirthDate \@ M}}
{SET bd {BirthDate \@ d}}
{SET yy {DATE \@ yyyy}}
{SET mm {DATE \@ M}}
{SET dd {DATE \@ d}}
{SET md{=IF((mm=2),28+(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0)),31-((mm=4)+(mm=6)+(mm=9)+(mm=11)))}}
{Set Years{=yy-by-(mm<bm)-(mm=bm)*(dd<bd) \# 0}}
{Set Months{=MOD(12+mm-bm-(dd<bd),12) \# 0}}
{Set Days{=MOD(md+dd-bd,md) \# 0}}
{IF{={IF{={BirthDate \@ "dddd"}}= "!*" 0 1}+{IF{={BirthDate \@ "MMMM"}}= "!*" 0 1}+{IF{by}= "!*" 1 0}+{IF{BirthDate \@ yyyyMMdd}<{DATE \@ yyyyMMdd} 0 1}}= 0 "If your Date of Birth was {Birthdate \@ "d MMMM yyyy"}, then your age is {Years} Year{IF{Years}= 1 "" s}, {Months} Month{IF{Months}= 1 "" s} and {Days} Day{IF{Days}= 1 "" s}." "Data entry error!"}}