[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 578
  • Last Modified:

Troubleshooting a field script to calculate a date

I'm teaching myself how to use the field editing in Microsoft Word 2007 using an example from http://addbalance.com/word/datefields2.htm
I have entered it all in manually adding all the { } using ctrl+f9. At the end I right clicked the field and selected 'update field' and the only value showing based on today's date was: 8,2008

The attached code is pasted from the website, not from what I've entered. I'm having trouble getting the code on the clipboard, I'm going over it again now carefully. I'm putting this question here now in case any expert out there can see a glaring syntax error or comment on common oversights.

Thank you
{ QUOTE "{ SET " Delay" "14"  }
{  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" }" } } } }" }

Open in new window

0
sirjulio
Asked:
sirjulio
1 Solution
 
GrahamSkanRetiredCommented:
That particular set of nested fields is the reason that I always recommend using VBA for date arithmetic. In my opinon it is far too difficult to type in for for practical use.

It is certainly not the place to start learnng about fields.

You could try attaching a document with your efforts here. Perhaps someone will have the time to debug it.

0
 
sirjulioAuthor Commented:
Thanks Graham that actually sounds like a great idea. I'll close this question here and create a new one in the VBA zone
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now