Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Word Formula: IF Statement

Status
Not open for further replies.

WPCMS

Technical User
Jun 28, 2007
29
US
I am trying to create a formula for a Word document that shows only the new start dates for our services. The table will have rows of types of services. Each time a service changes we print a letter of all of the services. All of the services in our system have start dates but we want the service with the new change to only show the new start date.

I was trying to create a formula that says

If the start date is greater than today, then show, else null

or

If the start date is equal to current month, then show, else null

Please let me know how I should set this up as our users are merging the doc then they have to manually delete the old service start days.

Thank you in advance.
 
Hi WPCMS,

Assuming your start date is bookmarked 'StartDate':
{IF{StartDate \@ YYYYMMDD}> {Date \@ YYYYMMDD} "Text to Show"}

You also mention merging, so for a mailmerge:
{IF{MERGEFIELD StartDate \@ YYYYMMDD}> {Date \@ YYYYMMDD} "Text to Show"}

For month-level resolution, simply delete the 'DD' parts of the expressions.


Cheers
[MS MVP - Word]
 
I am not sure what you mean about bookmarked.

I ended up with

IF <<Start_date>> > <<TODAY>> "<<Start_Date>>" ""

But this does not work.

Can you tell me what I need to do with this formula to make it work?

Thanks
 
Hi WPCMS,

You need to input the formula as:
{IF{MERGEFIELD Start_Date \@ YYYYMMDD}> {Date \@ YYYYMMDD} {MERGEFIELD Start_Date ##}}
using Ctrl-F9 to create the field braces.

Note: where I've got the ##, you should insert the appropriate field switch to format the date as required. Possible date formatting switches include:
. \@ "dddd, d MMMM yyyy";
. \@ "ddd, d MMMM yyyy";
. \@ "d MMM yyyy";
. \@ "dd/MMM/yyyy";
. \@ "d-MM-yy";
Note: Note: you can swap the d, M, y expressions around, but you must use uppercase 'M's for months (lowercase 'm's are for minutes). You can also use 'D's for days and 'Y's for years.




Cheers
[MS MVP - Word]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top