How do I display the previous month in a MS Word field?

Christa picture Christa · Apr 2, 2013 · Viewed 7.1k times · Source

I would like to learn how to display the name of the month before the current month in a Word 2003 document. I have tried over and over again to follow the instructions I found on the link below, but no matter what I try I get one of several errors, something about syntax or picture switches that I don't understand. I have tried searching and I think I just don't know how to actually put the code into MS Word. Would anyone be willing to help me take this code from your forum and enter it into my document?

Thank you!

How do I display the next month in a Microsoft Word field?

Answer

user1379931 picture user1379931 · Apr 2, 2013

The trouble with field coding is that there are a number of locale-related dependencies. That is one possible reason why you have been unable to make the suggestions in the links you mention work. Another reason is that one suggestion there cannot possibly have worked :-)

I suggest that you try to insert the following nested field in your document, and see if that works:

{ QUOTE "2013-{ = { DATE \@M } - 1 \#00;;'12' }-01" \@MMMM }

Some notes: - use ctrl-F9 to insert a pair of the special field code braces {} (you can't just type them on the keyboard) - you can toggle between "field code view" and "field result view" using alt-F9. You may need to do that as you proceed - these fields will not automatically update. To ensure that the result is for the current date, select the nested field and click F9

To insert the nested field: - click F9. You should see { }

  • click between the braces, and type QUOTE "2013--01" \@MMMM

so you see { QUOTE "2013--01" \@MMMM }

click between the two "--" and click ctrl-F9 again so you see { QUOTE "2013-{ }-01" \@MMMM }

click between the new { } and type = - 1 \#0;;'12'

so you see { QUOTE "2013-{ = - 1 \#00;;'12' }-01" \@MMMM }

click after the ' = ' and click ctrl-F9 again so you see { QUOTE "2013-{ = { } - 1 \#0;;'12' }-01" \@MMMM }

click between the new { } and type DATE \@M

so you see { QUOTE "2013-{ = { DATE \@M } - 1 \#00;;'12' }-01" \@MMMM }

Then select the nested field, clcik F9,and click alt-F9 as necessary to display the result.

This approach probably differs from what you have seen before because

  • it doesn't use a nested IF to generate the correct month
  • it uses a YYYY-MM-DD format to generate a date that can be used to extract the month name. That's because using formats such as DD/MM/YYYY depend on the locale (i.e. they may work if the date format is DD/MM/YYYY but not if it's MM/DD/YYYY. As far as I know, YYYY-MM-DD is either locale-independent, or as locale-independent as it gets.