View Single Post
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Future Dates - Again!

If { MERGEFIELD YYYCZ1 } produces a date with the ordinal, there is no way
that you can use the calculated fields to produce a future date. Word fields
do not allow extraction of parts of the field to enable you to lose the
ordinal. Your best bet is to explore the possibility of exporting your data
without the ordinal i.e. as 28/05/2008.

--

Graham Mayor - Word MVP

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



Chris Stammers wrote:
Hello,

I have this code which was given to me before however the date field
I am trying to calculate from is formatted in our AS400 as 28th May
2008, so is a full date without day, but including ordinals. My
question is this: how do I amend this code to allow for the format of
the original field, in this case, the AS400 field would be placed in
a document as { MERGEFIELD YYYCZ1 }. The code I have is below.

Many thanks.

Regards,
Chris

{QUOTE{SET Delay 14}{SET a{=INT((14-{MERGEFIELD DATEFIELD \@
M})/12)}}{SET b{={MERGEFIELD DATEFIELD \@ yyyy}+4800-a}}{SET
c{={MERGEFIELD DATEFIELD \@ M}+12*a-3}}{SET d{MERGEFIELD DATEFIELD \@
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*10^6+mm*10^4+yy \# "00'-'00'-'0000"}
\@ "dddd, d MMMM yyyy"}