Date Calculations based on Document Property

R

RizzKid

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where you want
the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and paste it to
the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're done, press
Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
 
M

macropod

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod said:
Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and paste it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

macropod said:
Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod said:
Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and paste it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

macropod said:
Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod said:
Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

macropod said:
Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

macropod said:
Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using File|Save As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

macropod said:
Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
....
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
....
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

macropod said:
Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using File|Save As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

macropod said:
Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

macropod said:
Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

macropod,

Thanks for sticking with me. That did the trick. I never would have guessed
that you can use QUOTE when not displaying output. I really appreciate all
the help you provided.

Cheers!
- RizzKid

macropod said:
Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

macropod said:
Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay' and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi RizzKid,

A thought: your penultimate post referred to a season start date. Is that date something that is determined on a regular calendar
basis (eg 1 Jane, 1 Apr, 1 Jul, 1 Oct)? If so, it should be possible to use IF fields to construct a DATE test and use the result of
the test to SET the season start date without any user intervention.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
macropod,

Thanks for sticking with me. That did the trick. I never would have guessed
that you can use QUOTE when not displaying output. I really appreciate all
the help you provided.

Cheers!
- RizzKid

macropod said:
Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find
some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

:

Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using
File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you
copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where
the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay'
and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When
you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

Macropod, I hope you're still answering questions!

As I mentioned last year at this time, the annual document gets prepared
each March. The code we worked out last year worked amazingly well -- I set
about 8 document properties, hit F9, and hundreds of dates and days of the
week updated magically. And correctly as well.

Then I went to produce a PDF from my Word doc. I regularly use Acrobat 6 to
do this, as Word 2007's publish feature is not as robust as even the old
Acrobat. Every time I try to print the doc to Adobe, though, it converts all
my dates to a single wrong date. After trying about a dozen different ideas,
I finally tried Word's publish feature -- and it did the same thing.
Fortunately, I then tried saving the Word doc as a new doc, making it a mail
merge letter with an empty recipient list, then merging to a new doc. The new
doc looks the same as the original, but doesn't lose the dates when I print
it to Adobe. Pretty bizarre, but at least I've got a workaround so I can get
it out the door this weekend.

Any ideas on why my original doc with tons of SET's doing date computations,
gets all fouled up the moment I try to create a PDF?

macropod said:
Hi RizzKid,

A thought: your penultimate post referred to a season start date. Is that date something that is determined on a regular calendar
basis (eg 1 Jane, 1 Apr, 1 Jul, 1 Oct)? If so, it should be possible to use IF fields to construct a DATE test and use the result of
the test to SET the season start date without any user intervention.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
macropod,

Thanks for sticking with me. That did the trick. I never would have guessed
that you can use QUOTE when not displaying output. I really appreciate all
the help you provided.

Cheers!
- RizzKid

macropod said:
Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find
some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

:

Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using
File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you
copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1}, where
the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay'
and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When
you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
M

macropod

Hi RizzKid,

A problem you can run into when using the same bookmark names for the date calculations, as my Date Calc tutorial does, is that the
'final' content of those bookmarks is determined by the last field to use them. When you close and re-open the document, this can
mess up the calculations. This happens to my Date Calc tutorial, for example.

The simple solution for PDF creation (assuming you're 'printing' to PDF using the Adobe Print driver (or some other PDF distiller))
is to make sure the document is set to 'update fields' for printing - see under Tools|Options|Print. For other forms of PDF
generation, you might need to force a global field update (eg Ctrl-A, F9) then either lock (Ctrl-F11) or unlink the fields
(Ctrl-Shift-F9) before doing the conversion. Personally, I'd choose locking, since you can unlock the fields later
(Ctrl-Shift-F11) - but you can't undo the unlinking - and some PDF conversion processes require the Word document to be saved before
proceeding.

--
Cheers
macropod
[MVP - Microsoft Word]


RizzKid said:
Macropod, I hope you're still answering questions!

As I mentioned last year at this time, the annual document gets prepared
each March. The code we worked out last year worked amazingly well -- I set
about 8 document properties, hit F9, and hundreds of dates and days of the
week updated magically. And correctly as well.

Then I went to produce a PDF from my Word doc. I regularly use Acrobat 6 to
do this, as Word 2007's publish feature is not as robust as even the old
Acrobat. Every time I try to print the doc to Adobe, though, it converts all
my dates to a single wrong date. After trying about a dozen different ideas,
I finally tried Word's publish feature -- and it did the same thing.
Fortunately, I then tried saving the Word doc as a new doc, making it a mail
merge letter with an empty recipient list, then merging to a new doc. The new
doc looks the same as the original, but doesn't lose the dates when I print
it to Adobe. Pretty bizarre, but at least I've got a workaround so I can get
it out the door this weekend.

Any ideas on why my original doc with tons of SET's doing date computations,
gets all fouled up the moment I try to create a PDF?

macropod said:
Hi RizzKid,

A thought: your penultimate post referred to a season start date. Is that date something that is determined on a regular calendar
basis (eg 1 Jane, 1 Apr, 1 Jul, 1 Oct)? If so, it should be possible to use IF fields to construct a DATE test and use the result
of
the test to SET the season start date without any user intervention.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

RizzKid said:
macropod,

Thanks for sticking with me. That did the trick. I never would have guessed
that you can use QUOTE when not displaying output. I really appreciate all
the help you provided.

Cheers!
- RizzKid

:

Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find
some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you
said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

:

Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you
could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using
File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you
copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your
document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1},
where
the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay'
and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When
you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
to give me the second date, but it merely gives me a "1".
Changing the final line to
{a \@ "dddd, MMMM d, yyyy"}}
for debug purposes gives me "Sunday, March 16, 2008", which is the current
date.
What am I missing? (Other than all that time I could have spent with my
family today)
 
R

RizzKid

I changed the print option and that solved the problem when using Adobe.
Thank you so much.

Till next year...

macropod said:
Hi RizzKid,

A problem you can run into when using the same bookmark names for the date calculations, as my Date Calc tutorial does, is that the
'final' content of those bookmarks is determined by the last field to use them. When you close and re-open the document, this can
mess up the calculations. This happens to my Date Calc tutorial, for example.

The simple solution for PDF creation (assuming you're 'printing' to PDF using the Adobe Print driver (or some other PDF distiller))
is to make sure the document is set to 'update fields' for printing - see under Tools|Options|Print. For other forms of PDF
generation, you might need to force a global field update (eg Ctrl-A, F9) then either lock (Ctrl-F11) or unlink the fields
(Ctrl-Shift-F9) before doing the conversion. Personally, I'd choose locking, since you can unlock the fields later
(Ctrl-Shift-F11) - but you can't undo the unlinking - and some PDF conversion processes require the Word document to be saved before
proceeding.

--
Cheers
macropod
[MVP - Microsoft Word]


RizzKid said:
Macropod, I hope you're still answering questions!

As I mentioned last year at this time, the annual document gets prepared
each March. The code we worked out last year worked amazingly well -- I set
about 8 document properties, hit F9, and hundreds of dates and days of the
week updated magically. And correctly as well.

Then I went to produce a PDF from my Word doc. I regularly use Acrobat 6 to
do this, as Word 2007's publish feature is not as robust as even the old
Acrobat. Every time I try to print the doc to Adobe, though, it converts all
my dates to a single wrong date. After trying about a dozen different ideas,
I finally tried Word's publish feature -- and it did the same thing.
Fortunately, I then tried saving the Word doc as a new doc, making it a mail
merge letter with an empty recipient list, then merging to a new doc. The new
doc looks the same as the original, but doesn't lose the dates when I print
it to Adobe. Pretty bizarre, but at least I've got a workaround so I can get
it out the door this weekend.

Any ideas on why my original doc with tons of SET's doing date computations,
gets all fouled up the moment I try to create a PDF?

macropod said:
Hi RizzKid,

A thought: your penultimate post referred to a season start date. Is that date something that is determined on a regular calendar
basis (eg 1 Jane, 1 Apr, 1 Jul, 1 Oct)? If so, it should be possible to use IF fields to construct a DATE test and use the result
of
the test to SET the season start date without any user intervention.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

macropod,

Thanks for sticking with me. That did the trick. I never would have guessed
that you can use QUOTE when not displaying output. I really appreciate all
the help you provided.

Cheers!
- RizzKid

:

Hi Hi RizzKid,

if you save the document using File|Save As on the season start date, then CREATEDATE will work. Otherwise you'll have to find
some
other way, such as the DOCPROPERTY field, that you'll have to modify periodically.

This change to the code for Day2, which is what I suggested, works:
{SET Day2 {QUOTE
{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}-{mm}-{yy}" \@ "dd-MM-yyyy"}}

With it, you can retrieve the Day2 result, in dd-mm-yyyy format via a REF field coded as {REF Day2}. This result is what you
said
you needed: "Somehow DayTwo has to end up being in "dd-mm-yyyy" format".

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

The document I have describes the various procedures that have to occur at
different points in time during a season. The start date of the season
changes from year to year. FILLIN won't work, because I don't want a reader
of the doc to have to know the start date every time they open the doc.
CREATEDATE won't work because the season start is not based on the document
creation date. I simply want to take the document I create for 2008, update
the start-of-season date next year and save the 2009 version.

Back to the code: Your code looks like:
{QUOTE
...
{SET yy{=100*e+g-4800+INT(i/10)}}
"{mm}-{dd}-{yy}" \@ "dddd, d MMMM yyyy"}
which displays the final date in the format "day, date month year."

What I want is:
...
{SET yy{=100*e+g-4800+INT(i/10)}}
{SET DayTwo{"{mm}-{dd}-{yy}"}}
and then later in the document display the value as
{REF DayTwo \@ "dddd, d MMMM yyyy"}

The above SET of DayTwo produces various errors, and I have not been able to
produce a string value that can be used later with a format.

:

Hi Hi RizzKid,

For Day one, have you thought of using a FILLIN field or an ASK field to solicit the starting date? Alternatively, you
could
change
the 'DATE' strings to 'CREATEDATE', so that the document would use the date it was created. Then, if you save it using
File|Save
As,
the 'CREATEDATE' value will update to that date and the other dates will calculate from that.

To create a bookmark for day two, without displaying it, simply:
.. select the entire field
.. press Ctrl-F9 to embed that field in a new field
.. type 'SET Day2' inside the first field brace
.. press F9 to update.
From then on, you can use a REF field to refer to the Day2 bookmark. If you want to change the date's format, change the
formatting
switch at the end of the existing field, from 'dddd, d MMMM yyyy' to 'dd-MM-yyyy' (note the uppercase Ms).

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Urghhhhh... I responded with pages, and it then told me the server was
unavailable and I lost my complete response. Let's try again. (Urghhhh)

Thank you for your response. However, I just figured out that the "$" at the
start of "$Day1" was the culprit. Apparently that special character can't be
used in field manipulation (although it lets me define it as a document
property). It also appears that digits don't work well, so "$Day1" has now
become "DayUno" and it works fine.

But maybe document properties are not the best way to approach this project.
What I want is to define a base point, DayOne, and maybe a few others, at the
start of the document, either by a document property, a few {SET}s, or some
better method that you can recommend. Then there will be copies of the code
you've already given me to compute the other relative days. But unlike your
code, I don't want the computations to display the DayTwo value there, but I
need to save the DayTwo bookmark in a format that can be used throughout the
document in various ways:
{REF {DayTwo @\ "dddd,d MMMM yyyy"}} etc.
I've tried and tried, but I can't get a SET to create a value for DayTwo
that is usable later on in the document. Somehow DayTwo has to end up being
in "dd-mm-yyyy" format, but I just can't figure out how to get it that way.
I'd be grateful for any help you can give.

:

Hi RizzKid,

My error - you don't need 'REF' for DOCPROPERTY fields, so change every instance of 'DATE' to {DOCPROPERTY $Day1}.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Thanks for the help, but I'm still having issues. Copying your example and
setting Delay to 1 correctly gives me "Tuesday, 18 March 2008" (tomorrow's
date). I go to Document Properties, choose Advanced Properties, add a new
custom property called $Day1 of type Date with value 3/1/2008 (March 1 in
U.S. format). Back in the doc I hit Alt/F9, delete the first occurrence of
the 4 characters "DATE", hit Ctrl/F9, then type "REF DOCPROPERTY $Day1"
without the quotes. I do Ctrl/A and Alt/F9, then F9 to update it. It still
says "Tuesday, 18 March 2008" and at the bottom I get "One or more of the
fields in the selection could not be updated."

:

Errata:
For the second field, also change:
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}
to:
{SET jd{=jd+Delay}}

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Hi RizzKid,

I suspect you haven't examined the field codes fully - they're rather more complex than what you've posted. If you
copy
the
field
coding from the example in 'Calculate a day, date, month and year, using n days delay' to the place in your
document
where
you
want the first calculated date to appear and press Alt-F9, the code should appear as:

{QUOTE
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ 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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}

You'll need to change 'SET Delay 14' to 'SET Delay 1' and every instance of 'DATE' to {REF DOCPROPERTY $Day1},
where
the
field
braces for {REF DOCPROPERTY $Day1} are created in pairs via Ctrl-F9. This will give you your first calculated date.

Now make a second copy of the field from the example in 'Calculate a day, date, month and year, using n days delay'
and
paste
it
to the second location. Then delete the lines:
{SET Delay 14}
{SET a{=INT((14-{DATE \@ M})/12)}}
{SET b{={DATE \@ yyyy}+4800-a}}
{SET c{={DATE \@ M}+12*a-3}}
{SET d{DATE \@ d}}
The remainder of the code:
{QUOTE
{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}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"}
will give you your second calculated date.

Copy this second edited field to each of the other locations for the third and subsequent calculated dates. When
you're
done,
press Alt-F9 to hide the field coding, then Ctrl-A followed by F9 to update all the fields.

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

Maybe I'm going about this all wrong, but I just can't get date calculations
to work right. I'm using Word 2007. I have a document that gets updated once
a year and needs to display various date information based on a starting date
for the new year. So I set a custom document property ($Day1) as a date type
(3/1/2008). I need it to print out a week's worth of daily information in the
form "dddd, MMMM d, yyyy". So it should display
Saturday, March 1, 2008 ...
Sunday, March 2, 2008 ...
and so on for seven days.
I have read the Woody's Lounge article, but can't make his examples work for
me. I would have expected:
{SET QUOTE
{SET a{={DOCPROPERTY $Day1}}}
{SET b{=a+1}}
{b \@ "dddd, MMMM d, yyyy"}}
 

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