Solved

Is there a Word merge code to show next month instead of the current month

Posted on 2006-11-27
14
370 Views
Last Modified: 2012-05-05
I am currently using this field code to get the current month:

{DATE \@ "MMMM YYYY" \* MERGEFORMAT }

Which shows

November 2006


Is there a field code that I can enter to show next months date?

i.e.

December 2006


I basically need to alter the field to add one month to the current  date, so I guess if its possible it would be something like this:


{ADDMONTH(DATE,1) \@ "MMMM YYYY" \* MERGEFORMAT }
0
Comment
Question by:nmcdermaid
  • 7
  • 3
  • 2
  • +2
14 Comments
 
LVL 7

Expert Comment

by:gbahri
ID: 18025460
Hi nmcdermaid,

Try this field code:

{ QUOTE { IF { DATE \@ "M"}= 1 "12" "{={DATE \@ "M" }+1}"}/1/{DATE \@ "YYYY"} \@ "MMMM YYYY" \* MERGEFORMAT}

Hope, this is what you were looking for,

Thanks,

GBahri
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18025522
It probably is what I want, but MS Word won't accept it.

In the 'field' dialog box, the OK button is greyed out when I paste that string in.

It isn't greyed out when I just paste DATE in.

Therefore there may be an issue with opening/closing brackets and or quotes? I'm not too familiar with this type of syntax, it may be quicker if you could take another look.

... plus I'm in Australia here so maybe the date format when concatenating the string needs to d/m/y instead of m/d/y
0
 
LVL 22

Expert Comment

by:Dreamboat
ID: 18025527
To insert a set of the { } brackets, you must use Ctrl+F9. You cannot copy/paste them.

So, edit the existing merge field by changing it to say QUOTE, then hit space, then Ctrl+F9, then type IF, etc...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 7

Expert Comment

by:gbahri
ID: 18025630
For each pair of {} you'll have to use Ctrl+F9 as Dreamboat has said. Your field code should match with string so as to work correctly. For the Date part, I dont' think that will create any problem, give this a try.

Thanks,

GBahri
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18025867
Thanks guys. I gotta run now but I'll try it tommorow, it sounds like what I'm after!
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18033108
OK, I've created a field with just "DATE" in it, then I've hit "toggle field codes" and edited it.

Using CTRL-F9 (noting that it inserts BOLDED braces) I have entered the above formula. Then I hit 'toggle field codes' ....

its just showing todays date:


29/11/2006


The curious thing is if I flick back to the field code or copy and paste, it changes it to this:

{ QUOTE /1/ \@ "MMMM YYYY" \*}


.. which is a nice suprise after I laboriously typed it in!

Is there a way we can break this into bits to check which segment is causing issues?
0
 
LVL 7

Expert Comment

by:gbahri
ID: 18034198
Hi,

I think you are missing some field codes. You'll have to replicate each bit as it is. All the paired curly braces '{ }' denotes field code (you'll have to use Ctrl-F9. Altogether, there are Six field codes). I'm also attaching a zipped word file with above working field code. If you wish, you can copy field code from this document, its working fine.

https://filedb.experts-exchange.com/incoming/ee-stuff/1539-nmcdermaid.zip

cheers,

GBahri
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18035286
Thanks for that I'll give it a try tommorow.
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18050290
OK, its almost working except for the position of the month.

Basically its stuck on January because the MMMM format string is picking up the /1/ in the middle. The first number (which is the day in Australian format) is definitely moving along correctly.


Therefore it definitely needs to be in Australian format:

How do I move the /1/ to the front:

for example,

1/4/2007 for an input of March 2006  as opposed to 4/1/2007


I've tried messing with the codes but to no avail.


Thanks for your assistance so far, I'm learning a lot.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 18057949
Strewth Bruce,
Without getting too involved, in Pommieland our name for the fourth month is April. I guess there's more to Oz than just being excellent at team games.
;)
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18058263
LOL Crikey!

But when you add one to the month March becomes April (as per the original question), so I guess we both see these things slightly differently :)



0
 
LVL 4

Expert Comment

by:David Linker
ID: 18065359
From a fellow Aussie:

{ QUOTE "1/"{ IF { DATE \@ "M"}= 12 "1" "{={DATE \@ "M" }+1}"}"/"{ IF { DATE \@ "M" }= 12 {={ DATE \@ "yyyy" }+1 {DATE \@ "yyyy"} } \@ "MMMM yyyy" \* MERGEFORMAT}

Note - the original answer while helpful checked for January then made it December - when you need to check for December and make it January.  You also have to increment the year by one if it is December.  I fixed both these errors.

The field codes that keep "disappearing" after you type it in - you need to highlight just the text representing the "disappearing" code and press shift-F9 to make that piece visible as a code instead of it's value

I've also moved the month in to the middle to cope with our Aussie date format :-)
This will give you the answer you're after.  Note that the space is important - especially the space betweeen the = and 12 - which occurs in two places.




0
 
LVL 4

Accepted Solution

by:
David Linker earned 500 total points
ID: 18065504
A Word .DOC containing this field is attached here:
https://filedb.experts-exchange.com/incoming/ee-stuff/1593-Next-Month.zip 
0
 
LVL 30

Author Comment

by:nmcdermaid
ID: 18109864
Thats the ticket, thanks for that!
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question