Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-13-2013, 09:03 AM
Charles Kenyon Charles Kenyon is offline Use formula in "Age" field to calculate age Windows 7 64bit Use formula in "Age" field to calculate age Office 2013
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,535
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
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Use formula in &quot;Age&quot; field to calculate age Word options "field shading" reverts to "when selected" PaulBurcham Word 1 04-20-2013 11:18 AM
Use formula in &quot;Age&quot; field to calculate age How to choose a "List" for certain "Heading" from "Modify" tool? Jamal NUMAN Word 2 07-03-2011 03:11 AM
Cannot see all recipients in "to" field in new mail message (Outlook 2007) sinjinx Outlook 0 12-15-2010 08:13 AM
Use formula in &quot;Age&quot; field to calculate age office 2003 - "to" field problem in new email bruce_hyman Outlook 2 10-25-2010 08:04 PM
merge field formatting problem with "text to be inserted before" wissam Mail Merge 0 12-13-2009 12:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:08 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft