View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default How do I create a merge field that will do the following?

Hi sokab,

A simple field construction like:
{QUOTE
{SET Delay -1}
{SET MDATE {MERGEFIELD SourceDate}}
{SET m{=MOD({MDATE \@ MM}+Delay+11,12)+1}}
{SET y{=INT({MDATE \@ yyyy}+(Delay+{MDATE \@ M}-1)/12)}}
"{m}-{y}" \@ "MMMM yyyy"}
will return the month and year. But - do you want just the month and year, or the day, month and year (taking account of different
month lengths)?

Whichever it is you can see how to do that and just about everything else you might want to do with dates in Word, in my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
or
http://www.gmayor.com/downloads.htm#Third_party
In particular, look at the topic titled 'Automatically insert a past or future date'.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"sokab" wrote in message ...
I need to create a Word mergefield that will return last month's name and
year. For example: We are currently in the month of September. When the
field is merged, it will return "August 2007". If the letter is merged in
October, the field will return "September 2007".