Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2017, 10:03 AM
mshu31 mshu31 is offline 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 64bit
Novice
Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's & Entered Date
 
Join Date: Aug 2016
Posts: 1
mshu31 is on a distinguished road
Default Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's & Entered Date


If anyone can help me with these formulas, I would be very grateful. I can not figure out what I'm doing wrong with entering these Nested If Formulas in my word document's inserted field, and I've been trying to tweak this for about a week now with no results. I've been using the Ctrl+F9 to enter the brackets and input the code within the applicable brackets, but I guess that I might have the brackets in the wrong places maybe? Incorrect use of the space bar? I really have no idea. I have tried numerous different ways to rewrite this and none of them work.

Basically, what I'm trying to do here is have a field inserted into my Word Document which takes the date from a user fill-in field (a person's birth date entered, bookmarked as Text2) and the field in question would return the person's current and exact age in full, non-rounded years with respect to the current date.

by the way, I hope I'm drafting this thread correctly, as well. Or posting it in the correct place on this forum. If I'm not please let me know, and I will try to fix it. This is my first time posting something here.

The field codes that I can't figure out are as follows (verbatim):

{ IF { { { DATE \@ "YYYY" } - { REF Text2 \@ "YYYY" } = 70 } { IF { { { DATE \@ "MM" } <= { REF Text2 \@ "MM" } } { IF { { { DATE \@ "DD" } < { REF Text2 \@ "DD" } } { = { { DATE \@ "YYYY" } -1 } - { REF Text2 \@ "YYYY" } } { = { DATE \@ "YYYY" } - { REF Text2 \@ "YYYY" } } } } { = { DATE \@ "YYYY" } - { REF Text2 \@ "YYYY" } } } } { = { DATE \@ "YYYY" } - { REF Text2 \@ "YYYY" } } } }
Reply With Quote
  #2  
Old 02-09-2017, 02:04 PM
macropod's Avatar
macropod macropod is offline Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's &amp; Entered Date Windows 7 64bit Nested If Statements in Formula Field to Produce the Diffrnc in Years Between Today's &amp; Entered Date Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
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

Thread Tools
Display Modes


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 07:13 AM.


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