Future Dates - Again!

C

Chris Stammers

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"}
 
G

Graham Mayor

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Chris Stammers

Thanks Graham. I did manage to get it to work however I had to change the SET
DELAY to 42! I suspect that this is because, when it was left at 14, it is
taking 14 days away from a proper, created date field, therefore making the
result 28 days in the past rather than 14 days in the future. This is what
one of our lead programmers thought. I have decided instead to use the word
system date, which obviously works. I do have a question on that though: the
first time I used this code, the future date used to come through on the
finished merged documents as a mergefield, much like { DATE } does, and would
change when you opened the document a few days later. This doesn't seem to be
happening now, and the future date seems hard coded to the merged document.
Has something changed within the code, or do newer versions of word handle
this type of programming differently?

Thanks.

Regards,
Chris
 
G

Graham Mayor

I suspect the problem is simply a reluctance to automatically update a
calculated field on a document that has been re-opened. However if you merge
the document, the calculated field in the merged document is converted to
text and so cannot be updated.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Chris Stammers

Thanks Graham. It's far from a problem, because I never wanted the date to
change anyway!

Regards,
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top