Forum Discussion
Andreas1991
Jun 04, 2024Copper Contributor
Automatic Age Calculation in Word Document
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"...
Charles_Kenyon
Jun 04, 2024Bronze Contributor
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!"}}