date code question

P

pcupcakes

I am trying to modify the date code field to automatically populate a date in
my word document X number of days from the present date. Would I be able to
modify the following to accomplish this task and if so, how would you go
about doing it?

{ DATE \@ "dddd MM/dd/yy"}

So, when this document is edited today (08/18/05), the code will produce:
Thursday 08/18/05

I want to modify the code so it is always smart enough to add X days to the
date automatically. So, if I wanted it to display a date 7 days into the
future (X=7), output would automatically be adjusted to display:

Thursday 08/25/05

How can the date code listed above be modified to accomplish this? Thanks.
 
C

Charles Kenyon

This is more complex than you might imagine, but it can be done. The
following field does a CreateDate plus 7 days.

{ QUOTE "{ SET " Delay" "7" }
{ SET "DaysInMonth" { IF { CreateDate \@ "MM" } <> 2
{ = ROUND(30.575*{ CreateDate \@ "MM" },0)-
ROUND(30.575*{ = { CreateDate \@ "MM" } -1 },0) }
{ IF { = MOD( { CreateDate \@"yy" } , 4 ) } > 0 "28" "29" } } }
{ SET "NextMonth" { IF { CreateDate \@ "MM" } = 12 "1/97"
"{ = { CreateDate \@ "MM" } + 1 }/97 } }
{ IF { = { REF "Delay" } + { CreateDate \@ "dd" } } <= {
REF"DaysInMonth" }
{ CreateDate \@ "MMMM { = { REF "Delay" } + { CreateDate \@ "dd" } },
yyyy"}{ QUOTE { NextMonth \@ "MMMM" }
{ = { REF "Delay" } + { CreateDate \@ "dd" } - { REF"DaysInMonth" } },
{ IF { CreateDate \@ "MM" } <> 12 { CreateDate \@ "yyyy" }
{ CreateDate \@ "{ = 1 + { CreateDate \@ "yyyy" } \# "xxxx" }" } } } }" }

Do _not_ try to type this! See http://addbalance.com/word/datefields2.htm
for information on the different kinds of ways to make a date calculation
work. It includes links to pages with fields and an explanation of different
macros that can be used instead of fields. It also includes a link to Chris
Woodman's Add-In that created the field you see.

--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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