Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2017, 02:04 PM
macropod's Avatar
macropod macropod is online now Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's & Entered Date Windows 7 64bit Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's & Entered Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,359
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You should change your text formfield's internal bookmark name to 'BirthDate' and use a field constructed as:


Code:
{QUOTE
{SET sy{BirthDate \@ yyyy}}
{SET sm{BirthDate \@ M}}
{SET sd{BirthDate \@ d}}
{SET ey{Date \@ yyyy}}
{SET em{Date \@ M}}
{SET ed{Date \@ d}}
{Set Years{=ey-sy-(em<sm)-(em=sm)*(ed<sd)}}
"{Years} Year{IF{Years}= 1 "" s}"}
Do make sure the 'BirthDate' formfield has the 'calculate on exit' property checked.

Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field construction are all required. Although I've used linebreaks in the field code, they're no needed - they just add clarity.

To see how to do just about everything you might want to do with dates in Word, check out my Microsoft Word Date Calculation Tutorial (which is where the above field code comes from):
https://www.msofficeforums.com/word/...-tutorial.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Have Text Entered in Content Control / PreDefined Field Populate Field in Footer bzowk Word 1 04-14-2016 11:50 AM
Formula to subtract one month from due date field in reminder field ghumdinger Outlook 1 10-01-2011 12:09 AM
Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's &amp; Entered Date Using Field Codes to Calculate 5 years from a Date vandy Word 1 09-23-2009 11:32 AM
new appointment date always reverts back to today's date msills Outlook 0 08-24-2007 08:57 AM
Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's &amp; Entered Date Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:48 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