alborg
Thu Oct 18 01:50:01 PDT 2007
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
"Graham Mayor" wrote:
> 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
>
> My web site www.gmayor.com
> Word MVP web site
http://word.mvps.org
> <>>< ><<> ><<> <>>< ><<> <>>< <>><<>
>
>
> ribspreader wrote:
> > 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?
> >
> > "alborg" wrote:
> >
> >> Are you talking about a locked document or a popup UserForm?
> >>
> >> There are several ways to calculate the age, the most popular being
> >> something like this:
> >>
> >> Function Age(varDOB As Variant)
> >> Dim varAge As Variant
> >> If IsNull(varDOB) Then Age = 0: Exit Function
> >> varAge = DateDiff("yyyy", varDOB, Now)
> >> If Date < DateSerial(YEAR(Now), Month(varDOB), Day(varDOB)) Then
> >> varAge = varAge - 1
> >> End If
> >> Age = varAge
> >> End Function
> >>
> >> Cheers,
> >> Al
> >>
> >> "ribspreader" wrote:
> >>
> >>> 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
>
>
>