View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor
 
Posts: n/a
Default Insert a future date

Apart from the fact that it should be Mergefield MemoDate and not MemoDate,
I can't see anything wrong with that.
Does the unaltered code from Macropod's document work correctly? It does
here.

In case Macropod isn't watching this group, I'll copy your query to him for
comment.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Bryan L wrote:
Graham,

No, I'm actually using the Merge Field code rather than the macro. As it
turns out, it looks like I pulled my sample from MacroPod's
"WORD Date & Time Manipulation; Tips & Techniques" document, from the
section "Date Calculations In A Mailmerge". My dates are merged into
the document from a SQL 2000 data source. Here's a sample from my
document:
The above policy will expire at 12:01am on Bpol_ExpirationDate. In
order for the carrier to provide a renewal quote we will need the
following items returned to our office no later than {QUOTE
{SET Delay 14}
{SET a{=INT((14-{MemoDate \@ M})/12)}}
{SET b{={MemoDate \@ yyyy}+4800-a}}
{SET c{={MemoDate \@ M }+12*a-3 }}
{SET d{MemoDate \@ 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)+111
{SET mm{=i+3-12*INT(i/10)}}
{SET yy{=100*e+g-4800+INT(i/10)}}
{QUOTE{=dd*10^6+mm*10^4+yy \- "00'-'00'-'0000"} \@
dddd, MMMM d, yyyy"}}:

I removed the MERGEFIELD entry (on line 3 in his original: {MERGEFIELD
MergeDate \@ d/MM/yyyy}) because it resulted in the unprocessed date
displaying immediately preceding the calculated date. I modified the
display mask on the final line to the format I liked. I've changed
the SET Delay line to the following:

{SET Delay 14}
{SET Delay 7}
{SET Delay -7}
{SET Delay -14}
{SET Delay (-7)}

Positive numbers work correctly. Negative numbers don't, with
whatever syntax I've attempted. I haven't found any actual samples
that show negative numbers being used in this (I was looking for one
to check for any special syntax requirements).

I hope this clarifies things, let me know if I can provide you with a
copy of his doc or anything else.

Thanks again,

Bryan

______________________

"Graham Mayor" wrote in message
...
I take it you are using the macro?

mask = "d MMMM yyyy" ' Set Date format
Default = "-30" ' Set default.

Will insert the date 30 days in the past? ie 13 December 2005
What do you have for these two settings?

Did you checkout the link that has examples of using fields for this?

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Bryan L wrote:
Graham,

I've used your sample on the linked page and it works great for
future dates; however, I can't get it to work properly with
negative numbers for past dates. For example, if I change the
Delay to a negative number, the merged document gets a calculated
date even further in the future than its positive equivalent. Has
anyone else run across this and found a solution? I've looked at
the code, but before I try a deep step-by-step analysis I want to
make sure I'm not reinventing the wheel (not to mention I don't
think I'm qualified to necessarily get it right!).
Thanks,

Bryan



"Graham Mayor" wrote in message
...
See http://www.gmayor.com/insert_a_date_...than_today.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Mark Ashley wrote:
This may be a dumb question, but I can't figure out how to get
Word (2003) to insert a future date. For example, insert the
date that is 30 days from the current date.

Thanks for any help. I can't believe the time I've spent trying
to figure this out.