View Single Post
  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Lani
 
Posts: n/a
Default Merge of a calculated date produces an error

I found a date calculation code that works on your Date Calc 'tutorial'.

I had trouble figuring out why it did not work consistently when I
subtracted dates, but then I found a post explaining that I had to change the
output from d/mm/yyyy to mm/d/yyyy and now it works great. Thank you so much.

"macropod" wrote:

Hi Lani,

Part of the problem is that the code you're using only works reliably with a
maximum of 28 days. This limitation is mentioned on the site where you
obtained the code.

For a more reliable solution for this and just about everything else you
might want to do with dates in Word, check out my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902


Cheers


"Lani" wrote in message
...
I am using Microsoft Word 2002. I copied the following code from
www.addbalance.com (I changed the bookmark name and number of days being
subtracted):

{QUOTE {SET Delay "29"}}{SET "NextPrevMonth" {IF {SALEDATE \@ "MM"} = 1
"12/97" "{ = { SALEDATE \@ "MM"} - 1 }/97" }}{SET "DaysInMonth" {IF {
NextPrevMonth \@ "MM"} 2{ = INT(30575*{NextPrevMonth \@ "MM"
}/1000+1/2)-INT(30575*{ ={NextPrevMonth \@ "MM"} - 1 }/1000+1/2) }{ IF { =
INT({SALEDATE \@ "yy" }/4) } = { = { SALEDATE \@ "yy"}/4) }"29"

"28" } } }{
IF { = {SALEDATE \@ "dd"} - {REF Delay \* MERGEFORMAT} } 0{QUOTE {
SALEDATE \@ "MMMM" }" "{ = { SALEDATE \@ "dd" } - { REF Delay \*

MERGEFORMAT
} \# "0" }", "{ SALEDATE \@ "yyyy"}""}{QUOTE {NextPrevMonth \@ "MMMM" }"

"{ =
{ SALEDATE \@ "dd"} - ( REF Delay \* MERGEFORMAT} + {DaysInMonth} \# "0"
}", "{ IF { SALEDATE \@ "MM"} 1 { SALEDATE \@ "yyyy"}{ = { SALEDATE \@
"yyyy"} - 1 \# "xxxx"}}""}}

When I merge the document with any SALEDATE in March, I receive an error
page that reads "A field calculation error occurred in record 2." When I
close the error page, the document I merged is underneath and the

calculation
is correct (unless the SALEDATE is 03/01/2006 then it merges February 0,
2006). I suspect that this has something to do with February only having

28
days. Can anyone tell me what I can do to eliminate the error? Also, as

an
added bonus, does anyone know how I can change the code so it won't merge
February 0, 2006?