View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default Adding days to Merge Field

Hi TotallyConfused,

Your field coding won't work. You need to feed Word something it can digest.

The field I referred you to in my Date Calc 'tutorial' document looks like:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{ MergeDate \@ M})/12)}}
{SET b{={ MergeDate \@ yyyy}+4800-a}}
{SET c{={ MergeDate \@ M}+12*a-3}}
{SET d{ MergeDate \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
{SET e{=INT((4*(jd+32044)+3)/146097)}}
{SET f{=jd+32044-INT(146097*e/4)}}
{SET g{=INT((4*f+3)/1461)}}
{SET h{=f-INT(1461*g/4)}}
{SET i{=INT((5*h+2)/153)}}
{SET dd{=h-INT((153*i+2)/5)+1}}
{SET mm{=i+3-12*INT(i/10)}}
{SET yy{=100*e+g-4800+INT(i/10)}}
"{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

As per my previous response, you need to edit the field so that you get:

{QUOTE
{SET Delay 3}
{SET a{=INT((14-{ MergeDate \@ M})/12)}}
{SET b{={ MergeDate \@ yyyy}+4800-a}}
{SET c{={ MergeDate \@ M}+12*a-3}}
{SET d{ MergeDate \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
{SET jd{=jd+(MOD(jd,7)4)*(7-MOD(jd,7))}}
{SET e{=INT((4*(jd+32044)+3)/146097)}}
{SET f{=jd+32044-INT(146097*e/4)}}
{SET g{=INT((4*f+3)/1461)}}
{SET h{=f-INT(1461*g/4)}}
{SET i{=INT((5*h+2)/153)}}
{SET dd{=h-INT((153*i+2)/5)+1}}
{SET mm{=i+3-12*INT(i/10)}}
{SET yy{=100*e+g-4800+INT(i/10)}}
"{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

Note the change to the 2nd line and the new 8th line that I've inserted.

Take note too of the tutorial's 'Introductory Notes'.

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

"TotallyConfused" wrote in message
...
Thanks for responding. This is what I have : I put {{SET Delay 3}DATE \@
"MMMM d, yyyy" \*MERGEFORMAT}{SET jd{=jd+(MOD(jd,7)4*(7-MOD(jd,7))}

This is what I have and it is not working. I am probably now reading it
right. Can you please tell me what I am doing wrong. I am trying to
understand this. I do not work with Word a lot but by doing this it will
save us a lot of time. I assume "jd" is for Julian Day?

Thank you.



"macropod" wrote:

Hi TotallyConfused,

To see how to add 3 days to a mailmerge date, check out 'Date Calculations In A Mailmerge' in my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902

Note that the example field adds 14 calendar days, not 3 business days. To add 3 business days, which presumably means skipping
over
weekends, you'd need to expand the field coding (select it and press Shift-F9) and:
.. change '{SET Delay 14}' to '{SET Delay 3}'
.. add a new field after the one coded as '{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}'. The
new
field should be coded as {SET jd{=jd+(MOD(jd,7)4)*(7-MOD(jd,7))}}, with the field braces (ie '{ }') created in pairs via Ctrl-F9
(you can't just copy & paste them from here).
Skipping over public holidays as well takes a lot more work. I'm currently working on an update to the document to show how to do
this, but it's not quite ready for release.

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

"TotallyConfused" wrote in message
...
Please can someone tell me how to revise this merge field to add 3 business
working days. I have a date field and I have to add a due date field (DATE\@
"MMMM d, yyyy"\*MERGEFORMAT), 2007. the due date field needs to be greater
by 3 business working than the date field. I would appreciate some helping
me with this. I was referred to macropod, and I have tried everything, can't
seem to make it work. Thank you in advance for any help you can provide.