Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Chris Stammers Chris Stammers is offline
external usenet poster
 
Posts: 46
Default Future Dates - Again!

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

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



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Chris Stammers Chris Stammers is offline
external usenet poster
 
Posts: 46
Default Future Dates - Again!

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

"Graham Mayor" wrote:

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




  #4   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!

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

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




Chris Stammers wrote:
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

"Graham Mayor" wrote:

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



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Chris Stammers Chris Stammers is offline
external usenet poster
 
Posts: 46
Default Future Dates - Again!

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

Regards,
Chris

"Graham Mayor" wrote:

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

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




Chris Stammers wrote:
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

"Graham Mayor" wrote:

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




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Word automatically send reminders on specific future dates? eyedrequired Microsoft Word Help 3 March 13th 08 06:24 AM
Can Word automatically send reminders on specific future dates eyedrequired Microsoft Word Help 2 March 13th 08 06:04 AM
Entering fields for future dates? meganfelicity Microsoft Word Help 2 June 27th 07 09:33 AM
How to calculate Future Dates? designgeek Microsoft Word Help 4 April 7th 06 12:43 PM
Windows explorer dates to match Word dates John Microsoft Word Help 0 October 17th 05 11:43 PM


All times are GMT +1. The time now is 09:42 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"