View Single Post
 
Old 12-13-2013, 09:03 AM
Charles Kenyon Charles Kenyon is offline Windows 7 64bit Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,150
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by rossjp View Post
I have tried =DateDiff("yyyy",DOB,ReviewDate)+Int(Format(DOB,"m mdd").Format(ReviewDate,"mmdd")) This formula was tried in a field identified as Age but did not return anything. DOB and ReviewDate are other fields in the document both identifies as such in their properties.
This looks like an Excel formula rather than a field calculation, to me. Field date math looks a lot more complex.

The basic field, on page 11 of Paul's tutorial, is:
{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!"}}

That one uses an Ask field to query for the date.
The next field looks for the birthdate in a bookmark and may be what you are looking for.

{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}}"Your age is {Years} Year{IF{Years}= 1 "" s}, {Months} Month{IF{Months}= 1 "" s} and {Days} Day{IF{Days}= 1 "" s}."}

You can see these field by using the Alt-F9 toggle to display field codes.

This isn't rocket science but seems a bit like alchemy because of the complexities of the calendar as well as the assumptions built into Word and Windows. These fields do not work for dates before January 1, 1901.

Read the tutorial, including the introductory part. Paul's tutorial is the best explanation of this stuff that I know, anywhere. You won't find it in books, and I don't think you'll find it on the Microsoft site.

Using Fields in Microsoft Word
Reply With Quote