View Single Post
 
Old 09-12-2023, 09:16 AM
JohnDohe JohnDohe is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Mar 2015
Posts: 7
JohnDohe is on a distinguished road
Default How to use/create code in MS Word to calculate and display age in years?

Hi!

I am not a programmer so please ... don't be too rough on me!

In an MS Word (vintage 2010) document I need to calculate age in years from a birthdate and a chosen date.

I've done a lot of searching and hope this can work:
Redirecting

{QUOTE{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 Years{=yy-by-(mm<bm)-(mm=bm)*(dd<bd) \# 0}}


Ultimate goal: to be able to click on a dropdown calendar field(not sure if this is the correct word to use!) to choose the BirthDate,
then use another dropdown calandar field(?) to enter a DATE, then have MS Word calculate the age in years between those two dates,
and only display the age in years (not the BirthDate nor the DATE) in the final document.


My problem is that the above code seems to refer to field code(s) and I have no idea how to work with them. Above my pay grade!

But I can follow directions

Please lend a guiding hand with step-by-step instructions for how to use the above code to calculate the age in years from
a birthdate and another date.

If the above code is not the "right stuff" please advise what I should use.

Thanks so much!
Reply With Quote