calculating age in word xp

R

ribspreader

i want to list a birthdate on one line and todays date on another, and then
in a third spot have the persons age calculated. Can anyone tell me how to
do this. I am new to this and would need step by step instructions. Help
please
 
R

ribspreader

I'm afraid I am clueless about how to input this into a locked document
template. I created the template, lock it, then dictate and save under a new
name and keep using the original template. There are several drop down menus
I use, and it automatically inserts todays date in one field. I want to use
that field, and a Date of Birth field. How do I get it to use these two
fields, and then how to I input the equations you described?
 
G

Graham Mayor

Calculated date fields are quite complex and do not need vba (though you can
certainly achieve the same ends with vba). If you want to calculate an age
from a DOB field using fields then the construction would be:

{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!"}}

To avoid errors in reproducing this, you can copy the construction from
Macropods excellent article on date fields which you can download from
http://www.gmayor.com/downloads.htm#Third_party

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

As you are using a formfield to collect the birthdate, you don't need the
ASK field in the example - instead name the Birth Date formfield Birthdate
and set it's type as Date.

Thus

{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
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!"}}

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
A

alborg

Hi Graham:

Of the 3 methods that I've encountered over the years, this seems so
complicated! Why not simply use VBA and the DateDiff method? One line does it
all...

Cheers,
Al
 
G

Graham Mayor

It is not complicated when someone else has already done all the work - just
a matter of copy/paste from the linked document - however I have no issues
with the vba method - I suggested this as an alternative, to show that it
can be done with fields.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
K

K. E. Melton

I simply need to enter the date in which a person will or has turned 18 (Age18) and 16 (Age16) in two formfields upon exiting the fromfield with their date of birth (DOB).
Don't know anything about macros or VB or SQL only know how to make a formfill form and protect it so that others can fill in the formfields, (i.e., name,dob,address, etc.).
I do not understand any of your answer, Graham, and when I toggle a field in one of your documents all I get is {QUOTE a whole bunch of return signs and a date "switch" whatever that is.
I need a simple, straightforward step by step method, please.
Thank you to anyone who can help.
Kathi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top