• Word Date Calculation Tutorial (v2.85)

    • This topic has 173 replies, 24 voices, and was last updated 17 years ago.
    Author
    Topic
    #386937

    This is fantastic! Can’t say that I will have the time to test it’s many nuances, but I’ve looked at your overall structure using SET & QUOTE fields. bravo

    Viewing 0 reply threads
    Author
    Replies
    • #673318

      Attached is a zipped Word file I’ve put together showing how to do date & time calculations using fields in Word.

      Topics covered include:
      [indent]. Date & Time Field Basics
      . Converting between Gregorian Calendar Dates, Julian Calendar Dates and Julian Day Numbers
      . Converting Between Dates and Days of The Year
      . Automatically Insert A Past Or Future Date, Adjusted By +/- A Number Of Days, Weeks etc,
      . Dealing with Weekends and Holidays in Calculated Dates
      . Interactively Calculate A Past Or Future Date
      . Date and Time Calculations In a Mailmerge or a Word Form
      . Date and Time Calculations In a Table
      . Express Today’s Date In Fiscal Year Terms
      . Calculate the # Days Difference Between Two Dates
      . Calculate the # Years Months & Days Difference Between Two Dates
      . Calculate Whether a Period Has Elapsed
      . Interactively Calculate a Person’s Age
      . Calculate a Stepped Date
      . Calculate a Stepped Date Range
      . Calculate a Date Sequence
      . Calculate Dates of Easter
      . Use Date (and/or Time) Comparisons to Vary Text
      . Converting Numeric Date Strings into Word Date Formats
      . Importing Date and Time Values from Excel and Access
      . Add or Subtract Two Time Periods
      . Calculate a Past or Future Time of Day
      . Calculate a Future Date & Time[/indent]
      Enjoy.

      Feedback welcome.

      This thread became very long and has been locked.

      Discussions continued in Post 432773 which also became very long and has been locked.

      Please feel free to post your questions thread starting at Post 595560

      Cheers

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

      • #673389

        Excellent piece of work, macropod!
        I’m sure it will forestall many future questions, so it should help in keeping your post count low. evilgrin

      • #690802

        Huloo – this collection of goodies looks to be handy!

        However, I’ve run into a snag using the “Interactively Calculate a Past or Future Date” routines (the same problem happens in all 3 version). If you use 31/07/2003 as the starting date and -7 as the variable, it correctly returns 24 Jul 2003. However, if you try 01/08/2003 with the same variable, it reads the 01/08 as January 8th instead of August 1st!!

        I thought maybe it was something with values less than 12 (number of months), but if you use 07/07/2003 and -7 it will correctly return 30 Jun 2003. What’s gone wrong here???

        I’m *really* hoping you can fix this, as I’ve got a project going where this would serve QUITE handily, though I’d have to change how it displays things though. What I’m shooting for is something that’ll prompt a merge user for a future date, subtract 7 calendar days from it (this is actually going to be a static value, and the formula doesn’t have to account for weekends or holidays) and display the 2 different dates in 2 different locations in the document. I’m used to using {set} and {fillin} fields for some really elaborate merges, so I’m hoping this can serve as the basis to do what I need!!!

        Mucho MUCHO thanks! I’ve been all over the MS newsgroups, but nothing I’ve found so far comes anywhere close to this!

        • #690827

          Sorry, not an answer, just a little observation:

          > if you use 07/07/2003 and -7 it will correctly return 30 Jun 2003.

          This is the date I’d use in my stage demo. No matter how the computer interprets the date I entered (whatever its regional settings), it’s always right! Thank you, thank you very much, right this way, bring your wallets… laugh

        • #690890

          Hi legalbear,

          I’m unable to replicate this problem. When I enter 01/08/2003 and -7, the field returns 25 July 2003. It does this even if I just enter 01/08, with no year.

          Since I can’t replicate the problem, I can’t tell you for sure what to do to fix it. However, if you change the first ASK field to:
          {ASK StartDate “What is the starting date, in dd mmm yyyy format, please?” d {DATE @ “dd MMM yyyy”}}
          that may resolve the issue by changing the way the day & month combo are entered/stored.

          As for changing the date formats, you’d need to make the change in three places. For example, to get:
          “If the starting date is Jul, 3 2003 and the offset is -7 days, then the new date is Jun, 26 2003.”
          you’d change the ASk field to:
          {ASK StartDate “What is the starting date, in mmm, dd yyyy format, please?” d {DATE @ “MMM, dd yyyy”}}
          change the {StartDate @ “d MMMM yyyy”}

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #691017

            Dude, you are SOOOOOOOOOOO cool – I took your suggestions – they pointed me in a coupla different directions to give me EXACTLY what I need!! I’ve attached a .zip of a Word document with the revised code in it for ya. Now, it only outputs the two desired dates, and uses a static 7-day period

            Mucho Mucho Thanks!!!
            clapping

            • #691113

              I see you’ve got the hang of it – but you might want to change the question in the ASK field to make it more relevant.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #754124

              Fabulous! Now can you make Word properly indicate a.m. and p.m. instead of the typographically incorrect AM and PM which seems to be endemic in Office? The rule is, paraphrasing the Chicago Manual of Style, “Lowercase a.m. and p.m. with periods, or the more traditional small capitals, ” AM and PM “”

            • #755204

              What, you didn’t like the am/pm solution I gave in the penultimate example? OK, I didn’t have a.m./p.m. (i.e. with the periods), but at least I had the lowercase representation – and the periods are there now if you want to see them.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #755226

              I am truly impressed Macropod. Who says you can’t teach a new dog old tricks…or, in this case, typography. Thanks again. Handy calculations to add to my toolkit!

            • #755227

              I am truly impressed Macropod. Who says you can’t teach a new dog old tricks…or, in this case, typography. Thanks again. Handy calculations to add to my toolkit!

            • #755205

              What, you didn’t like the am/pm solution I gave in the penultimate example? OK, I didn’t have a.m./p.m. (i.e. with the periods), but at least I had the lowercase representation – and the periods are there now if you want to see them.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #754125

              Fabulous! Now can you make Word properly indicate a.m. and p.m. instead of the typographically incorrect AM and PM which seems to be endemic in Office? The rule is, paraphrasing the Chicago Manual of Style, “Lowercase a.m. and p.m. with periods, or the more traditional small capitals, ” AM and PM “”

      • #697125

        Thanks for posting this, macropod. Nice job. This should be very useful for anyone who needs to do date calculations in a document.

      • #754476

        macropod,

        The first time I saw this back in May 2003, I was very impressed as I should be.

        Now I’m very confused.

        The thread shows a post # back in the May timeframe and lots of people responding back then. Time goes by and there are some responses in July. Then again time goes by and now we have a Dec posting (a 2nd with mine here). But the date on your post is Dec 7, 2003 while the post # is back in May. At least that’s what I’m seeing and l looked eleventeen times.

        I had saved your post back then. I saved the one attached to the Dec 7 post. I compared them. They are different. For example, very first line has Tips & Tricks now while it didn’t in May. Other differences too.

        So the Dec 7 posting is an edited version of your May posting but doesn’t show any edited on notation? Did it incorporate the July discussion with LegalBear on his/her problem? Did you edit your post from May to change the attachment?

        Thanks.

        Fred

        • #754486

          When you edit one of your own posts, you have the option to mark it as edited or not. The default option is No.

          Macropod has modified the attachment several times already; he marks the latest additions with *NEW* in the body of the post.

          • #754506

            HansV,

            Thanks for the quick answer. That’s almost what I thought (other than not knowing you had an option whether to mark an edit). I did see the new down at the bottom but wasn’t sure if this was new now or new another time. (Of course, I’d disagree with the default of not marking an edit but that’s a Lounge Matter.)

            I also saw in the thread that he didn’t seem to have problems, nor did Jefferson, on the Interactive Date calc. So I was also asking if anything was added to this new item to reflect any of that discussion, which looked like it was in July. Do you know?

            Fred

            • #754578

              Fred, my post was actually, sort of, a joke. (Maybe not very funny, but I must have been seeing some vendor demos around that time.) Please ignore my earlier comment for purposes of determining whether the problem is/was/has been solved.

            • #755180

              Jefferson,

              you thought I took you seriously? laugh

              Actually, I wasn’t sure that your response over the summer was of direct response to the questions I was concerned with, so I skipped it (read that as a nice way of saying ignored). But thanks for responding.

              Fred

            • #755181

              Jefferson,

              you thought I took you seriously? laugh

              Actually, I wasn’t sure that your response over the summer was of direct response to the questions I was concerned with, so I skipped it (read that as a nice way of saying ignored). But thanks for responding.

              Fred

            • #754579

              Fred, my post was actually, sort of, a joke. (Maybe not very funny, but I must have been seeing some vendor demos around that time.) Please ignore my earlier comment for purposes of determining whether the problem is/was/has been solved.

            • #754692

              Hi Fred,

              As you now know, I’ve been updated this progressively since the original post. Each time, I’ve highlighted any new examples with *NEW*. I’ve also been changing the version # on the post title, which now stands at 1.60.

              Cheers
              PS: No change was required as a result of the discussion on the Interactive Date calc.

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #755182

              hi macropod,

              I did notice lots of version numbers in the thread (1.00, 1.01, 1.1 and now 1.6). I did also notice the *NEW in the listing of topics. This is good stuff. I’ll probably show it off at my Word Workshop later in the month. You’ve saved me from planning half a lesson – at least. Thanks. salute

              Fred

            • #755183

              hi macropod,

              I did notice lots of version numbers in the thread (1.00, 1.01, 1.1 and now 1.6). I did also notice the *NEW in the listing of topics. This is good stuff. I’ll probably show it off at my Word Workshop later in the month. You’ve saved me from planning half a lesson – at least. Thanks. salute

              Fred

            • #754693

              Hi Fred,

              As you now know, I’ve been updated this progressively since the original post. Each time, I’ve highlighted any new examples with *NEW*. I’ve also been changing the version # on the post title, which now stands at 1.60.

              Cheers
              PS: No change was required as a result of the discussion on the Interactive Date calc.

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

          • #754507

            HansV,

            Thanks for the quick answer. That’s almost what I thought (other than not knowing you had an option whether to mark an edit). I did see the new down at the bottom but wasn’t sure if this was new now or new another time. (Of course, I’d disagree with the default of not marking an edit but that’s a Lounge Matter.)

            I also saw in the thread that he didn’t seem to have problems, nor did Jefferson, on the Interactive Date calc. So I was also asking if anything was added to this new item to reflect any of that discussion, which looked like it was in July. Do you know?

            Fred

        • #754487

          When you edit one of your own posts, you have the option to mark it as edited or not. The default option is No.

          Macropod has modified the attachment several times already; he marks the latest additions with *NEW* in the body of the post.

      • #754477

        macropod,

        The first time I saw this back in May 2003, I was very impressed as I should be.

        Now I’m very confused.

        The thread shows a post # back in the May timeframe and lots of people responding back then. Time goes by and there are some responses in July. Then again time goes by and now we have a Dec posting (a 2nd with mine here). But the date on your post is Dec 7, 2003 while the post # is back in May. At least that’s what I’m seeing and l looked eleventeen times.

        I had saved your post back then. I saved the one attached to the Dec 7 post. I compared them. They are different. For example, very first line has Tips & Tricks now while it didn’t in May. Other differences too.

        So the Dec 7 posting is an edited version of your May posting but doesn’t show any edited on notation? Did it incorporate the July discussion with LegalBear on his/her problem? Did you edit your post from May to change the attachment?

        Thanks.

        Fred

      • #782458

        Hi Macropod

        This looks great, and obviously lots of work done on your part. Thank you.
        Are you looking for any further “contributions”? I have a few date-related bits & pieces I’ve compiled over the years. Those that come to mind include:

        • #782904

          Hi Alan,

          I always open to suggestions. Indeed, quite a few of the examples in the file come from solutions I

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #782966

            Macropod

            It was actually post 341919 that reminded me of the date ordinal issue. I guess my code for this is a bit of a combination of a and b above grin. I hadn’t realized that your approach was specifically geared towards avoiding VBA; but now that you point it out it’s abundantly clear!

            Alan

            • #783115

              I must admit I’d be interested in your method of calculating the day of the week for historical dates – I work in the Regency period a lot (1811-1820 specifically, although often taken as French Revolution 1789 to Victoria 1837) and it would be great to have a quick way of finding out the day a date fell on!

              Ta muchly

            • #783163

              Hi Beryl

              My method is probably not an orthodox one, because I adapted it directly from a “trick” I learned as a kid, when my powers of mental arithmetic were good enough for me to work out such answers in my head. I could dig out the code and post it if you like (it’s javascript). If you want the general method, I’ll have to rely on a fete of memory. The answer you get is a number in the range 0 -> 6, with 0 = Sat, 1 = Sun, … 6 = Fri. I’ll try it with today’s date: 12 Feb, 2004…

              Start with the year and look at just the last 2 digits (=04) then divide by 12. Remember:

            • #783164

              Hi Beryl

              My method is probably not an orthodox one, because I adapted it directly from a “trick” I learned as a kid, when my powers of mental arithmetic were good enough for me to work out such answers in my head. I could dig out the code and post it if you like (it’s javascript). If you want the general method, I’ll have to rely on a fete of memory. The answer you get is a number in the range 0 -> 6, with 0 = Sat, 1 = Sun, … 6 = Fri. I’ll try it with today’s date: 12 Feb, 2004…

              Start with the year and look at just the last 2 digits (=04) then divide by 12. Remember:

            • #783116

              I must admit I’d be interested in your method of calculating the day of the week for historical dates – I work in the Regency period a lot (1811-1820 specifically, although often taken as French Revolution 1789 to Victoria 1837) and it would be great to have a quick way of finding out the day a date fell on!

              Ta muchly

          • #782967

            Macropod

            It was actually post 341919 that reminded me of the date ordinal issue. I guess my code for this is a bit of a combination of a and b above grin. I hadn’t realized that your approach was specifically geared towards avoiding VBA; but now that you point it out it’s abundantly clear!

            Alan

        • #782905

          Hi Alan,

          I always open to suggestions. Indeed, quite a few of the examples in the file come from solutions I

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #782459

        Hi Macropod

        This looks great, and obviously lots of work done on your part. Thank you.
        Are you looking for any further “contributions”? I have a few date-related bits & pieces I’ve compiled over the years. Those that come to mind include:

      • #783232

        Wow–I really appreciate the good ideas. I’m not sure if this is the best option for us. The “printdate” is inserted for a multi-function marco. Yes, we could add the delayed date into the macro. However, the example I gave of changing the date at 1:00 just an example. This time can very depending of factors such as workload where we may need to wait until later to change the date, we may have a rush special request very late in the day where we need to use a current date, etc. I realize changing the system date does reflect in other system-generating dating purposes. That really doesn’t seem to hinder us. In our instance, I believe changing the system date was a better option. I’m not sure what is restricting us from doing that in our present environment, whether it be Window XP or active directory. Maybe I should have posted this in a different classification. Any further input is welcome. As stated, I think I’ve received some great ideas–which may still be the way we go. I just want to visit all avenues before implementing. Thanks so much.

        • #783545

          Instead of advancing the date based on 1pm, 2 pm etc, maybe you should prompt the user with a Yes/No message box or an ASK field. Use this input to advance the date as required. You could modify macropod’s field post 342520 so that it advanced the date if the user responded ‘yes’ to the prompt. I feel that as changing the system date can affect many things (especially if you forget to change it back) you should try to avoid it where possible.

          Regards,

          Matthew

        • #783546

          Instead of advancing the date based on 1pm, 2 pm etc, maybe you should prompt the user with a Yes/No message box or an ASK field. Use this input to advance the date as required. You could modify macropod’s field post 342520 so that it advanced the date if the user responded ‘yes’ to the prompt. I feel that as changing the system date can affect many things (especially if you forget to change it back) you should try to avoid it where possible.

          Regards,

          Matthew

      • #783233

        Wow–I really appreciate the good ideas. I’m not sure if this is the best option for us. The “printdate” is inserted for a multi-function marco. Yes, we could add the delayed date into the macro. However, the example I gave of changing the date at 1:00 just an example. This time can very depending of factors such as workload where we may need to wait until later to change the date, we may have a rush special request very late in the day where we need to use a current date, etc. I realize changing the system date does reflect in other system-generating dating purposes. That really doesn’t seem to hinder us. In our instance, I believe changing the system date was a better option. I’m not sure what is restricting us from doing that in our present environment, whether it be Window XP or active directory. Maybe I should have posted this in a different classification. Any further input is welcome. As stated, I think I’ve received some great ideas–which may still be the way we go. I just want to visit all avenues before implementing. Thanks so much.

      • #795660

        I came here looking for a way to insert CREATEDATE (or any date) +30 days into an invoice. Which as any fule kno is a piece of cake in excelwith a date in A1 then =A1+30 then format as a date does the job. Your document does the job impeccably as far as I can see but – phew – 29 concatenated and nested fields! Is there no way word handles DATE +30 (days) more easily. ISTR doing a similar thing to get the previous month in a doc, which involved a load of IFing.
        Apart from that a magnificent piece of work.

        • #795747

          Hi Tim:
          I don’t know about easier, since macropod has placed the fields in an add-in & you can copy & paste from it if you want. I was able to located this thread which gave a macro solution, but didn’t work for that user.
          Cheers,

        • #795748

          Hi Tim:
          I don’t know about easier, since macropod has placed the fields in an add-in & you can copy & paste from it if you want. I was able to located this thread which gave a macro solution, but didn’t work for that user.
          Cheers,

        • #795853

          Hi Tim,

          Apart from using vba, which may or may not be considered simpler, there really doesn’t seeem to be an easy way to get Word to do date calculations. If Word stored dates as a number the way Excel does, it would be a trivial matter. But Word doesn’t do that and even Excel chokes on dates before 1/1/1900.

          As for getting the previous month, there is an example in the document that allows you to specify a number of months as the ‘delay’ parameter. Use that with -ve values for previous months.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #795994

            Thanks Phil and macropod: I agree that it’s all made very simple by cutting and pasting the fields, but I also need to explain it!
            There are a couple of VBA things that work (assume a bookmark named duedate)
            Mydate = Date
            Due = DateAdd(“d”, 30, Mydate)
            ActiveDocument.Bookmarks(“duedate”).Select
            Selection.InsertAfter Due

            or shorter in coarse VBA
            ActiveDocument.Bookmarks(“duedate”).Select
            Selection.TypeText Text:=Format(Date + 30, “d mmmm yyyy”)

            Tim

            • #796317

              Hi Tim,

              Yes, all of the calculations in the document can be done with vba but, as explained in a previous post “much of the r

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #796332

              Edited by Phil Rabichow to make the link clickable – see Help #19
              Hi Macropod,

              Thanks for your great document. I mentioned in in reply to a question on the Tek-Tips Microsoft Office Forum and received immediate responses re the quality of your work. Here is the thread if you would like to see the feedback:

              http://www.tek-tips.com/viewthread.cfm?SQI…D=68&page=3%5B/url%5D

              Once again great work!

              Regards,
              Peter Moran
              Melbourne!

            • #796333

              Edited by Phil Rabichow to make the link clickable – see Help #19
              Hi Macropod,

              Thanks for your great document. I mentioned in in reply to a question on the Tek-Tips Microsoft Office Forum and received immediate responses re the quality of your work. Here is the thread if you would like to see the feedback:

              http://www.tek-tips.com/viewthread.cfm?SQI…D=68&page=3%5B/url%5D

              Once again great work!

              Regards,
              Peter Moran
              Melbourne!

            • #797035

              Yes, I take your point about macro protection. I have indeed loked at the field codes and they are understandable! I never realised you could put soft returns in a field – that makes them far more comprehensible. A fantastic piece of work – is there a URL where the general public can download the document?

            • #797041

              Hi Tim,
              Re:[indent]


              is there a URL where the general public can download the document?


              [/indent]Anyone can do that right here, at: http://www.wopr.com/cgi-bin/w3t/showflat.p…d&Number=249902%5B/url%5D

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #797042

              Hi Tim,
              Re:[indent]


              is there a URL where the general public can download the document?


              [/indent]Anyone can do that right here, at: http://www.wopr.com/cgi-bin/w3t/showflat.p…d&Number=249902%5B/url%5D

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #797036

              Yes, I take your point about macro protection. I have indeed loked at the field codes and they are understandable! I never realised you could put soft returns in a field – that makes them far more comprehensible. A fantastic piece of work – is there a URL where the general public can download the document?

            • #796318

              Hi Tim,

              Yes, all of the calculations in the document can be done with vba but, as explained in a previous post “much of the r

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

          • #795995

            Thanks Phil and macropod: I agree that it’s all made very simple by cutting and pasting the fields, but I also need to explain it!
            There are a couple of VBA things that work (assume a bookmark named duedate)
            Mydate = Date
            Due = DateAdd(“d”, 30, Mydate)
            ActiveDocument.Bookmarks(“duedate”).Select
            Selection.InsertAfter Due

            or shorter in coarse VBA
            ActiveDocument.Bookmarks(“duedate”).Select
            Selection.TypeText Text:=Format(Date + 30, “d mmmm yyyy”)

            Tim

        • #795854

          Hi Tim,

          Apart from using vba, which may or may not be considered simpler, there really doesn’t seeem to be an easy way to get Word to do date calculations. If Word stored dates as a number the way Excel does, it would be a trivial matter. But Word doesn’t do that and even Excel chokes on dates before 1/1/1900.

          As for getting the previous month, there is an example in the document that allows you to specify a number of months as the ‘delay’ parameter. Use that with -ve values for previous months.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #795661

        I came here looking for a way to insert CREATEDATE (or any date) +30 days into an invoice. Which as any fule kno is a piece of cake in excelwith a date in A1 then =A1+30 then format as a date does the job. Your document does the job impeccably as far as I can see but – phew – 29 concatenated and nested fields! Is there no way word handles DATE +30 (days) more easily. ISTR doing a similar thing to get the previous month in a doc, which involved a load of IFing.
        Apart from that a magnificent piece of work.

      • #799011

        Are there any known bugs with the “Calculate a day, date, month and year, using n days delay” field ?

        I attempted to calculate the date 90 days from today (March 14, 2004). The result , Monday 6 December 2004, is incorrect. I then tried to calculate the date 70 days from now. The result , Sunday May 23 2004, is correct.
        Further “trial and error” revealed that the field calculation is incorrect for the following delays:
        Delay =18 to 29 (April 1-12)
        Delay = 48 to 59 (May 1-12)
        Delay = 79 to 90 (June 1-12)

        It appears that the algorithm has trouble calculating any date which falls in the first 12 days of future months.

        Any feedback would be appreciated.

        Regards,
        kleveck

        • #799121

          Hi kleveck,

          I’ve just re-tested the field and it is working correctly. The clue to your problem is in the output format you’ve specified in your (edited) post. The fields in the document are region-dependent and are coded to work on systems that are configured to display dates formatted as d/MM/yyyy (short form) or dddd, d MMMM yyyy (long form). Something I’ll need to note in the next update. Your ‘issue’ relates to a system that is configured to display dates formatted as MM/d/yyyy (short form) or dddd, MMMM d yyyy (long form). To obtain the correctly result is as simple as changing the expression ‘dd*10^6+mm*10^4+yy’ to ‘mm*10^6+dd*10^4+yy’. Adding the appropriate date switch will then display the result accordingly.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #799452

            Macropod,
            Thanks for your quick response. Yes, the issue was resolved by changing the date format expression per your instructions.

            clapping

            Regards,
            kleveck

          • #799453

            Macropod,
            Thanks for your quick response. Yes, the issue was resolved by changing the date format expression per your instructions.

            clapping

            Regards,
            kleveck

        • #799122

          Hi kleveck,

          I’ve just re-tested the field and it is working correctly. The clue to your problem is in the output format you’ve specified in your (edited) post. The fields in the document are region-dependent and are coded to work on systems that are configured to display dates formatted as d/MM/yyyy (short form) or dddd, d MMMM yyyy (long form). Something I’ll need to note in the next update. Your ‘issue’ relates to a system that is configured to display dates formatted as MM/d/yyyy (short form) or dddd, MMMM d yyyy (long form). To obtain the correctly result is as simple as changing the expression ‘dd*10^6+mm*10^4+yy’ to ‘mm*10^6+dd*10^4+yy’. Adding the appropriate date switch will then display the result accordingly.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #799012

        Are there any known bugs with the “Calculate a day, date, month and year, using n days delay” field ?

        I attempted to calculate the date 90 days from today (March 14, 2004). The result , Monday 6 December 2004, is incorrect. I then tried to calculate the date 70 days from now. The result , Sunday May 23 2004, is correct.
        Further “trial and error” revealed that the field calculation is incorrect for the following delays:
        Delay =18 to 29 (April 1-12)
        Delay = 48 to 59 (May 1-12)
        Delay = 79 to 90 (June 1-12)

        It appears that the algorithm has trouble calculating any date which falls in the first 12 days of future months.

        Any feedback would be appreciated.

        Regards,
        kleveck

      • #829933

        Like, WOW!! I have already put to use the function to put in yesterday’s date in a document – thanks. I thought I was a clever bunny a dozen years ago discovering “* ordinal” but all this just blows me away!! (BTW I’ve come here via Tek-Tips Forum). The answer is probably out there but what I need is to be able to determine what today’s Day of the Week is and then adjust the print field accordingly. I haven’t decided which way to do it but I have this Run Sheet that we report one day’s activity on the next day. We do this each day. For the weekend I will either print it on Friday with the field forward to Monday or visa versa, but I also want it to be used for every other day of the week as well. Can anyone help, please?

        • #829976

          Hi Des,

          To revert the date to Friday for a report printed on Saturday, Sunday or Monday, and to revert by one day in any other case, take the field in “Changing document dates during the course of a day” on page 4 and change the Delay formula to:
          =-1-(MOD(jd,7)=6)-(MOD(jd,7)=0)*2

          I’m not quite sure though what you mean by


          For the weekend I will either print it on Friday with the field forward to Monday or visa versa


          Can you explain this a bit more?

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #830034

            Thanx. This is all VERY new to me after years of VBA. What I meant was at the moment we have a ‘Backup Log’ sheet and you’d normally write today’s date in against ‘Date’ and then the appropriate date against ‘Backup Date’, e.g. today I wrote Date: Thursday 20th May, Backup Date: 19 May 2004. (Yes, I know the format is different – but hey, so am I!). What we have at present is a stack of pre-printed forms. If we were to print them off for daily use, would we want to print them off on the day or the previous day? So, if we print them on the day, today would come out as shown above. If we printed them the night before then today it would show Date: Friday 21st May 2004, Backup date: 20 May 2004. Similarly, printing on the day, I’d want Monday to come out as Date: Monday 24th May 2004, Backup Date 21 May 2004. If I chose the advance method I’d want to get the same result if I were printing it on the Friday, i.e. the delay would be + or – and the trigger day would be different. Sorry if I muddied the water a bit with the original comment but I thought it worth putting in in case it made a difference (no idea what) to the solution.

            I’ve just tried the modified formula and it’s showing Wednesday, 20 May 2004. Cool. This stuff just looks SO weird though! I was thinking about printing in advance because we have to print off a Daily Runsheet in advance.

            I’ve been playing around trying to get it to be ‘forward thinking’ and have got it to show Friday now by removing the initial -. I’ve changed my system date to Friday so the field now says Saturday. I’ve tried a bunch of things but can’t get the hang of what is the Day Of Week.

            Des.

            • #830442

              Hi Des,

              See if the attached does what you want. It’s based on the interactive date calculator from page 4, plus the superscripted ordinal day numbering demo from page 1and the delay formula from my previous post. This allows you to nominate the report day (with today’s date being given as the default), then calculates the weekday prior to that for the Backup date, reproducing the second version of your date formats along the way (though I can’t really tell wether your ordinals were meant to be superscripted).

              Cheers
              PS: This could, of course, all be done with vba …

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #830484

              Thanx. I’d really like to understand what the * – and / actually do, I’m used to multiply, subtract and divide from XL formulae. Is it possible to work things out? I think what I want to end up with is printing today for the next working day. I’m happy enough with the current field for the backup Date – Friday 21st May 2004 – I just need to work out how to jump forward 1 day for Monday thru Thursday and to jump forward 3 days if today is Friday; all without using VBA!!

              Des.

            • #831041

              Hi Des,

              The * and / perform multiplications and divisions, respectively. For more information on doing maths with Word fields, see post 365442.

              Most of the fields for calculating date offsets in the document use a gregorian calendar date to julian day number conversion, followed by addition of the required offset, then a julian day number to gregorian calendar date conversion. Hence the convoluted maths.

              To ‘jump forward’ by one day requires 1 to be added to the date’s julian day number. To test the day of the week, you can use MOD(julian day number,7). For Fridays, this returns 4 (error in the doco), which you can use to trigger a 3-day delay.

              So, for Monday thru Thursday you’ll want to use a delay of 1 and on Fridays you’ll want to use a delay of 3. There are various ways to code this, depending on what you want to achieve. For example:
              {SET Delay{=(MOD(jd,7)3)*(6-MOD(jd,7))}}, which is functionally equivalent to {SET Delay{=1+(MOD(jd,7)=4)*2+(MOD(jd,7)=5)}} and skips to Monday for Fridays thru Sunday.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #831042

              Hi Des,

              The * and / perform multiplications and divisions, respectively. For more information on doing maths with Word fields, see post 365442.

              Most of the fields for calculating date offsets in the document use a gregorian calendar date to julian day number conversion, followed by addition of the required offset, then a julian day number to gregorian calendar date conversion. Hence the convoluted maths.

              To ‘jump forward’ by one day requires 1 to be added to the date’s julian day number. To test the day of the week, you can use MOD(julian day number,7). For Fridays, this returns 4 (error in the doco), which you can use to trigger a 3-day delay.

              So, for Monday thru Thursday you’ll want to use a delay of 1 and on Fridays you’ll want to use a delay of 3. There are various ways to code this, depending on what you want to achieve. For example:
              {SET Delay{=(MOD(jd,7)3)*(6-MOD(jd,7))}}, which is functionally equivalent to {SET Delay{=1+(MOD(jd,7)=4)*2+(MOD(jd,7)=5)}} and skips to Monday for Fridays thru Sunday.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #830485

              Thanx. I’d really like to understand what the * – and / actually do, I’m used to multiply, subtract and divide from XL formulae. Is it possible to work things out? I think what I want to end up with is printing today for the next working day. I’m happy enough with the current field for the backup Date – Friday 21st May 2004 – I just need to work out how to jump forward 1 day for Monday thru Thursday and to jump forward 3 days if today is Friday; all without using VBA!!

              Des.

            • #830443

              Hi Des,

              See if the attached does what you want. It’s based on the interactive date calculator from page 4, plus the superscripted ordinal day numbering demo from page 1and the delay formula from my previous post. This allows you to nominate the report day (with today’s date being given as the default), then calculates the weekday prior to that for the Backup date, reproducing the second version of your date formats along the way (though I can’t really tell wether your ordinals were meant to be superscripted).

              Cheers
              PS: This could, of course, all be done with vba …

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

          • #830035

            Thanx. This is all VERY new to me after years of VBA. What I meant was at the moment we have a ‘Backup Log’ sheet and you’d normally write today’s date in against ‘Date’ and then the appropriate date against ‘Backup Date’, e.g. today I wrote Date: Thursday 20th May, Backup Date: 19 May 2004. (Yes, I know the format is different – but hey, so am I!). What we have at present is a stack of pre-printed forms. If we were to print them off for daily use, would we want to print them off on the day or the previous day? So, if we print them on the day, today would come out as shown above. If we printed them the night before then today it would show Date: Friday 21st May 2004, Backup date: 20 May 2004. Similarly, printing on the day, I’d want Monday to come out as Date: Monday 24th May 2004, Backup Date 21 May 2004. If I chose the advance method I’d want to get the same result if I were printing it on the Friday, i.e. the delay would be + or – and the trigger day would be different. Sorry if I muddied the water a bit with the original comment but I thought it worth putting in in case it made a difference (no idea what) to the solution.

            I’ve just tried the modified formula and it’s showing Wednesday, 20 May 2004. Cool. This stuff just looks SO weird though! I was thinking about printing in advance because we have to print off a Daily Runsheet in advance.

            I’ve been playing around trying to get it to be ‘forward thinking’ and have got it to show Friday now by removing the initial -. I’ve changed my system date to Friday so the field now says Saturday. I’ve tried a bunch of things but can’t get the hang of what is the Day Of Week.

            Des.

        • #829977

          Hi Des,

          To revert the date to Friday for a report printed on Saturday, Sunday or Monday, and to revert by one day in any other case, take the field in “Changing document dates during the course of a day” on page 4 and change the Delay formula to:
          =-1-(MOD(jd,7)=6)-(MOD(jd,7)=0)*2

          I’m not quite sure though what you mean by


          For the weekend I will either print it on Friday with the field forward to Monday or visa versa


          Can you explain this a bit more?

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #829934

        Like, WOW!! I have already put to use the function to put in yesterday’s date in a document – thanks. I thought I was a clever bunny a dozen years ago discovering “* ordinal” but all this just blows me away!! (BTW I’ve come here via Tek-Tips Forum). The answer is probably out there but what I need is to be able to determine what today’s Day of the Week is and then adjust the print field accordingly. I haven’t decided which way to do it but I have this Run Sheet that we report one day’s activity on the next day. We do this each day. For the weekend I will either print it on Friday with the field forward to Monday or visa versa, but I also want it to be used for every other day of the week as well. Can anyone help, please?

      • #834776

        Hi all, sorry for the newbie post – I’m sure with more hours(?!) of hacking macropod’s examples around, I’d stumble on the solution but I’m finding this msword field stuff a real struggle.

        I’m trying to convert a third-party date field from a CRM package into a nicely formatted date with ordinal.

        The CRM uses plain text in the doc like [# Schedule Date#] which it replaces with a date in the format dd/mm/yyyy (including forward-slashes).

        I’d like to end up with the “Long Date” format (which incidentally I don’t seem to be having much luck with even after checking my regional settings! – however dddd, d MMMM yyyy seems to work ok)

        So, could someone PLEASE help me to convert the format “31/05/2004” into something more presentable such as “Monday, 31st May 2004”?

        Many thanks in anticipation!

        • #834794

          Hi Calito,

          Assuming (always risky) that your CRM package uses a ‘proper’ date field, you should be able to display it via Shift-F9. If so, it will look something like:
          {DATE}
          In that case, substituting that field with one from the very first example in the Date Calc document will deliver the output in a format close to what you’re after. If you edit the field code from the first such example to look like:
          {QUOTE{DATE @ dddd}”, “{DATE @ “d” *Ordinal}” “{DATE @ “MMMM yyyy”}}
          you’ll get an output that exactly matches the one you’re after.

          If your CRM package inserts the date in plain text, you’ll need some means of putting that text string into a field for processing. For example, if you had a field coded as:
          {QUOTE{SET DtString “[# Schedule Date#]”}{DtString @ dddd}”, “{DtString @ “d” *Ordinal}” “{DtString @ “MMMM yyyy”}}
          and could get your CRM package to replace the [# Schedule Date#] string with a date, that could be used to achieve the desired result. Alternatively, you might use a macro in the Word document to move the plain [# Schedule Date#] string into the field for processing. Once you’ve gone that far, though, you may as well use the same macro to do all the processing and simply replace the [# Schedule Date#] string with the required output.

          Of course, the ‘best’ approach might be to see if your CRM package can insert the date in the required format without having to do any post-insertion processing in Word.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #835155

            Many thanks for the reply. The latter of the options is true – CRM program uses plain text entry in my ‘template’ and replaces it with the date set in my calendar.

            The second example worked in that the date string “5/06/2004” was inserted correctly into the field code. However, pressing Alt-F9 to show the result produced nothing… Not sure if this is a problem with my OS/Word setup or not?

            Have attached the doc in question. Would appreciate if you could take a look and see what you think?

            Thanks again!

            • #835205

              Hi Carlito,

              Alt-F9 toggles field code display on/off for the whole document, but doesn’t update a field’s result. To update the result, you’d need the field code display toggled off and then press F9, or print the document with the ‘update fields’ option checked under Tools|options|Print.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #835219

              Many thanks for the info macropod. It’s all working as I’d hoped!

              hailpraise

            • #835220

              Many thanks for the info macropod. It’s all working as I’d hoped!

              hailpraise

            • #835206

              Hi Carlito,

              Alt-F9 toggles field code display on/off for the whole document, but doesn’t update a field’s result. To update the result, you’d need the field code display toggled off and then press F9, or print the document with the ‘update fields’ option checked under Tools|options|Print.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

          • #835156

            Many thanks for the reply. The latter of the options is true – CRM program uses plain text entry in my ‘template’ and replaces it with the date set in my calendar.

            The second example worked in that the date string “5/06/2004” was inserted correctly into the field code. However, pressing Alt-F9 to show the result produced nothing… Not sure if this is a problem with my OS/Word setup or not?

            Have attached the doc in question. Would appreciate if you could take a look and see what you think?

            Thanks again!

        • #834795

          Hi Calito,

          Assuming (always risky) that your CRM package uses a ‘proper’ date field, you should be able to display it via Shift-F9. If so, it will look something like:
          {DATE}
          In that case, substituting that field with one from the very first example in the Date Calc document will deliver the output in a format close to what you’re after. If you edit the field code from the first such example to look like:
          {QUOTE{DATE @ dddd}”, “{DATE @ “d” *Ordinal}” “{DATE @ “MMMM yyyy”}}
          you’ll get an output that exactly matches the one you’re after.

          If your CRM package inserts the date in plain text, you’ll need some means of putting that text string into a field for processing. For example, if you had a field coded as:
          {QUOTE{SET DtString “[# Schedule Date#]”}{DtString @ dddd}”, “{DtString @ “d” *Ordinal}” “{DtString @ “MMMM yyyy”}}
          and could get your CRM package to replace the [# Schedule Date#] string with a date, that could be used to achieve the desired result. Alternatively, you might use a macro in the Word document to move the plain [# Schedule Date#] string into the field for processing. Once you’ve gone that far, though, you may as well use the same macro to do all the processing and simply replace the [# Schedule Date#] string with the required output.

          Of course, the ‘best’ approach might be to see if your CRM package can insert the date in the required format without having to do any post-insertion processing in Word.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #834777

        Hi all, sorry for the newbie post – I’m sure with more hours(?!) of hacking macropod’s examples around, I’d stumble on the solution but I’m finding this msword field stuff a real struggle.

        I’m trying to convert a third-party date field from a CRM package into a nicely formatted date with ordinal.

        The CRM uses plain text in the doc like [# Schedule Date#] which it replaces with a date in the format dd/mm/yyyy (including forward-slashes).

        I’d like to end up with the “Long Date” format (which incidentally I don’t seem to be having much luck with even after checking my regional settings! – however dddd, d MMMM yyyy seems to work ok)

        So, could someone PLEASE help me to convert the format “31/05/2004” into something more presentable such as “Monday, 31st May 2004”?

        Many thanks in anticipation!

      • #845560

        Thanks for creating and posting the date tricks for MS Word. It looks like something I could make great use of. However, when I downloaded your attachment, expanded and opened it, I could not get the field details. Doing SHIFT+F9 for the one I was interested expanded to this (with the leading text):

        Calculate a day, date, month and year, using n (301) days delay
        {QUOTE

        19-03-2005 @ “dddd, d

        • #845615

          In order to expand embedded fields, use Alt+F9. Shift+F9 only expands the outermost layer of the onion.

          In order to post what you see in the Lounge, try the macro(s) in Field Codes-to-Text Converter (and vice versa).

          Hope this helps.

        • #845616

          In order to expand embedded fields, use Alt+F9. Shift+F9 only expands the outermost layer of the onion.

          In order to post what you see in the Lounge, try the macro(s) in Field Codes-to-Text Converter (and vice versa).

          Hope this helps.

        • #846549

          Hi Z-Man,

          To expand any of the fields, you need to select it and press Shift-F9 – as per the instructions on page 1 – or use Alt-F9 to toggle field code displays on/off throughought the document as suggested by Jefferson. In many cases, merely placing the cursor withing the field and pressing Shift-F9 isn’t enough to expand the whole field.

          Cheers
          PS: I’ve been away for a few days, hence the delay in replying.

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

          • #846565

            Thanks for the replys. i saw the Shift-F9 on page 1, but didn’t know about the Alt-F9 to see the complete field details. I must have missed that in the instructions.

            Thanks, Jefferson, for the info on using Alt-F9. It got me what I needed on Tuesday.

          • #846566

            Thanks for the replys. i saw the Shift-F9 on page 1, but didn’t know about the Alt-F9 to see the complete field details. I must have missed that in the instructions.

            Thanks, Jefferson, for the info on using Alt-F9. It got me what I needed on Tuesday.

        • #846550

          Hi Z-Man,

          To expand any of the fields, you need to select it and press Shift-F9 – as per the instructions on page 1 – or use Alt-F9 to toggle field code displays on/off throughought the document as suggested by Jefferson. In many cases, merely placing the cursor withing the field and pressing Shift-F9 isn’t enough to expand the whole field.

          Cheers
          PS: I’ve been away for a few days, hence the delay in replying.

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

        • #846796

          Hi Z-Man

          Just for your further reference, the attachment is a quick summary of keyboard shortcuts associated with Field Codes.

          Alan

        • #846797

          Hi Z-Man

          Just for your further reference, the attachment is a quick summary of keyboard shortcuts associated with Field Codes.

          Alan

      • #845561

        Thanks for creating and posting the date tricks for MS Word. It looks like something I could make great use of. However, when I downloaded your attachment, expanded and opened it, I could not get the field details. Doing SHIFT+F9 for the one I was interested expanded to this (with the leading text):

        Calculate a day, date, month and year, using n (301) days delay
        {QUOTE

        19-03-2005 @ “dddd, d

      • #851409

        You are the man – at first I had trouble with the Past/Future dates – but then I actually read the document…

      • #851410

        You are the man – at first I had trouble with the Past/Future dates – but then I actually read the document…

      • #870313

        Hi,
        I was looking for a macro to calculate the # of week, found this. However various functions cannot be read I notice errors, also the function to calculate the week# gives only an error, would you be able to give me at least a function to calculate the week#
        Thanks in advance.
        Koen

        • #870459

          Hi Koen:
          I’m not macropod & I’m not positive that I can help, but could you be a little more specific about:
          1. What exactly you did?
          2. What error message/result did you get?
          3. What you’re trying to accomplish?

        • #870460

          Hi Koen:
          I’m not macropod & I’m not positive that I can help, but could you be a little more specific about:
          1. What exactly you did?
          2. What error message/result did you get?
          3. What you’re trying to accomplish?

      • #870314

        Hi,
        I was looking for a macro to calculate the # of week, found this. However various functions cannot be read I notice errors, also the function to calculate the week# gives only an error, would you be able to give me at least a function to calculate the week#
        Thanks in advance.
        Koen

      • #881379

        This is a very impressive file. Thanks for creating it.

        If you have the time, could advise on what I am doing wrong when using the “Calculate a day, date, month and year, using n (43) weeks delay”, please?

        I have inserted this in 4 or 5 places in a standard letter which I will send to various people at various times. The letter effectively sets out a timetable for the recipients to do certain things on certain dates. I have adjusted the “n” delay in each of the 4 or 5 places so that the letter shows a number of different dates by which the recipients are to do something. The intended timetable is the same for every recipient (that is, the first action is 2 weeks after the date of the letter, the second action 3 weeks later, etc). The actual dates of the timetable are intended to up-date every time I send the letter – because the date of the letter will be different every time I use it.

        The problem is that the letter I set up yesterday has all the intended timetabled dates as I expected. But when I opened the same document today, the date field for the letter date updated to today’s date, but the timetabled dates in the body of the letter did not up-date by 1 day as expected. They stuck on the dates that were automatically generated yesterday.

        Can you assist, please?

        Many thanks.

        Brian

        • #881383

          Did you update all the fields in the document? You can do this by typing Control-A to select the whole document and then F9 to update fields.

          StuartR

          • #881391

            Ah, yes. That does it! Thank you very much. I was hoping that there would be an automatic up-date, but obviously not (unless someone knows otherwise?).

            Thanks. A great site.

            Brian

            • #881393

              You can set the Update Fields option in Tools > Options > Print. This will cause Word to update all fields every time it prints a document.

              StuartR

            • #881401

              Even better! Many thanks.

              Brian

            • #881556

              Hi Brian,

              Another way to achive the same result would be to add an AutoOpen macro to your document, like:

              Sub AutoOpen()
              ActiveDocument.Fields.Update
              End Sub

              This will automatically update the fields in the body of the document each time you open it. Of course, if each recipient gets a different letter and/or you need to keep a record of the dates specified in each letter, you may also want to preserve the original dates. In that case, you might consider saving you document as a Word template and changing the four ‘DATE’ expressions to ‘CREATEDATE’.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #881621

              Thank you, Macropod. That gives me a second very satisfactory solution. I shall try it out and see whether it has any advantages over the Tools|Options|Print|Update fields option. Many thanks for your help.

              Brian

            • #881622

              Thank you, Macropod. That gives me a second very satisfactory solution. I shall try it out and see whether it has any advantages over the Tools|Options|Print|Update fields option. Many thanks for your help.

              Brian

            • #882254

              I have now got this working perfectly, thanks to your advice and that of StuartR.

              Can I push my luck and ask a further question?

              The routine for automatically calculating a future date uses today’s date as the basis for the calculation of the future date. Is it possible to run the routine in a document (in the way I am using it, as previously explained), so that the future dates are calculated from some other past date? In other words, can I get the future timetable to run, not from today’s date (the date the letter is generated amd printed), but from some earlier date (that would be recorded at the start of the letter)?

              Many thanks.

              Brian

            • #882491

              Hi Brian:
              In macropod’s download, take a look at the heading titled “Interactively Calculate A Past Or Future Date”. That should do what you want.

            • #882513

              Hi Phil,

              Many thanks for your reply.

              I had looked at that section of Macropod’s file, but it did not seem to provide the solution I wanted. The letter I am creating sets a timetable comprising 4 or 5 different stages at defined intervals from the start date. I like the simplicity of the “Automatically insert a past or future date: Calculate a day, date, month and year, using n (43) weeks delay” routine because that does not require an ASK routine to be run for each of the 4 or 5 stages of the timetable.

              It actually works perfectly well for what I want to do, because I just amend it to insert 4 or 5 future dates all calculated automatically from today’s date (which it takes from the PC’s clock, I guess). However, I was being ambitious and wanted to see whether I could make it insert those future dates, but all calculated (all with different offsets) from a start date other than today’s date.

              The “Interactively calculate a past or future date” routine would seem to need to prompt me 4 or 5 times for the “starting date” and the “offset” in order to achieve that.

              I don’t want to abuse the goodwill of this list or thread, so unless the answer is an obvious one (in which case, I shouldn’t be asking the question, I suppose), I don’t want to take up your (or other’s valuable time). But any further thoughts are very welcome, please.

              Many thanks.

              Brian

            • #882549

              Can you post a document that contains the following:

              (1) The date you want to use as the “start” date; and

              (2) The field code (include all its embedded field codes) that you want modified to use that “start” date?

              This will make it a lot easier to try to get a handle on the problem. Even if the calculation field is impossibly complicated to understand. smile

            • #883046

              Thanks for this suggestion. Macropod has now suggested a solution and I am going to try that one. Thanks for your reply.

              Brian

            • #883047

              Thanks for this suggestion. Macropod has now suggested a solution and I am going to try that one. Thanks for your reply.

              Brian

            • #882550

              Can you post a document that contains the following:

              (1) The date you want to use as the “start” date; and

              (2) The field code (include all its embedded field codes) that you want modified to use that “start” date?

              This will make it a lot easier to try to get a handle on the problem. Even if the calculation field is impossibly complicated to understand. smile

            • #882514

              Hi Phil,

              Many thanks for your reply.

              I had looked at that section of Macropod’s file, but it did not seem to provide the solution I wanted. The letter I am creating sets a timetable comprising 4 or 5 different stages at defined intervals from the start date. I like the simplicity of the “Automatically insert a past or future date: Calculate a day, date, month and year, using n (43) weeks delay” routine because that does not require an ASK routine to be run for each of the 4 or 5 stages of the timetable.

              It actually works perfectly well for what I want to do, because I just amend it to insert 4 or 5 future dates all calculated automatically from today’s date (which it takes from the PC’s clock, I guess). However, I was being ambitious and wanted to see whether I could make it insert those future dates, but all calculated (all with different offsets) from a start date other than today’s date.

              The “Interactively calculate a past or future date” routine would seem to need to prompt me 4 or 5 times for the “starting date” and the “offset” in order to achieve that.

              I don’t want to abuse the goodwill of this list or thread, so unless the answer is an obvious one (in which case, I shouldn’t be asking the question, I suppose), I don’t want to take up your (or other’s valuable time). But any further thoughts are very welcome, please.

              Many thanks.

              Brian

            • #882531

              Hi Brian:
              Don’t feel bad about asking questions. That’s what this forum is all about. Nevertheless, I don’t have an easy answer. Hopefully, macropod will see this & be able to provide one. smile

            • #882545

              Thanks, Phil.

              Brian

            • #882741

              Hi Brian,

              I’m away from home at the moment, so contact with the Lounge is a bit sporadic. As mentioned in my previous post, you could change the date calculated from to the document’s creation date. That date is always fixed, unless you do a ‘Save As’. If you want to use a variable ‘past’ (or future) starting date, you will need a different apporach, which I’ll outline below.

              Let’s start with your existing document, where you’ve got a number of these date calculations, and set things up for the solution you’re after.

              Select the second date calculation field in your document and press Shift-F9 to expose the field code. Reduce the ‘Delay’ value by the amount that is in your first date calculation field’s ‘Delay’ value. Delete the 2nd, 3rd, 4th and 5th SET fields. Change the SET jd field’s formula from:
              =d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+INT(Delay*7)
              to:
              =jd+INT(Delay*7)
              Change all instances of the dd,mm and yy pairs to dda,mma and yya, respectively. This is necesssary to preserve the displayed values when next you open the document. You could ignore this last step if that isn’t important, but if you don’t do this you’ll have to update the fields to get the correct values to display again.

              Repeat this process for each of the other fields, reducing the ‘Delay’ value by the sum of the preceding ‘Delay’ values and adding b, c and so on to all instances of the dd,mm and yy pairs.

              When you update the document, you should get the same results as previously. Now to make this work with dates of your choice.

              Now replace your first field with the one found under ‘Date Calculations In A Mailmerge’. Select this field and expand its field coding with Shift-F9. Reinsert your original ‘Delay’ value. Edit the ‘MERGEFIELD’ line to read:
              ASK StartDate “What is the starting date?”
              This changes the field to an interactive one. Change the SET jd field’s formula so that ‘Delay’ is replaced by ‘INT(Delay*7)’. Change all instances of ‘MergeDate’ to ‘StartDate’.

              When you’re finished, press Ctrl-A, then F9 to update the document (or run the macro or print it, depending on how you want to trigger the field updating). You will be asked once for the starting date and, having entered it, all of the date calculations will update accordingly.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #883048

              Brilliant! Many thanks.

              Brian

            • #883049

              Brilliant! Many thanks.

              Brian

            • #882742

              Hi Brian,

              I’m away from home at the moment, so contact with the Lounge is a bit sporadic. As mentioned in my previous post, you could change the date calculated from to the document’s creation date. That date is always fixed, unless you do a ‘Save As’. If you want to use a variable ‘past’ (or future) starting date, you will need a different apporach, which I’ll outline below.

              Let’s start with your existing document, where you’ve got a number of these date calculations, and set things up for the solution you’re after.

              Select the second date calculation field in your document and press Shift-F9 to expose the field code. Reduce the ‘Delay’ value by the amount that is in your first date calculation field’s ‘Delay’ value. Delete the 2nd, 3rd, 4th and 5th SET fields. Change the SET jd field’s formula from:
              =d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+INT(Delay*7)
              to:
              =jd+INT(Delay*7)
              Change all instances of the dd,mm and yy pairs to dda,mma and yya, respectively. This is necesssary to preserve the displayed values when next you open the document. You could ignore this last step if that isn’t important, but if you don’t do this you’ll have to update the fields to get the correct values to display again.

              Repeat this process for each of the other fields, reducing the ‘Delay’ value by the sum of the preceding ‘Delay’ values and adding b, c and so on to all instances of the dd,mm and yy pairs.

              When you update the document, you should get the same results as previously. Now to make this work with dates of your choice.

              Now replace your first field with the one found under ‘Date Calculations In A Mailmerge’. Select this field and expand its field coding with Shift-F9. Reinsert your original ‘Delay’ value. Edit the ‘MERGEFIELD’ line to read:
              ASK StartDate “What is the starting date?”
              This changes the field to an interactive one. Change the SET jd field’s formula so that ‘Delay’ is replaced by ‘INT(Delay*7)’. Change all instances of ‘MergeDate’ to ‘StartDate’.

              When you’re finished, press Ctrl-A, then F9 to update the document (or run the macro or print it, depending on how you want to trigger the field updating). You will be asked once for the starting date and, having entered it, all of the date calculations will update accordingly.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #882546

              Thanks, Phil.

              Brian

            • #882532

              Hi Brian:
              Don’t feel bad about asking questions. That’s what this forum is all about. Nevertheless, I don’t have an easy answer. Hopefully, macropod will see this & be able to provide one. smile

            • #882492

              Hi Brian:
              In macropod’s download, take a look at the heading titled “Interactively Calculate A Past Or Future Date”. That should do what you want.

            • #882255

              I have now got this working perfectly, thanks to your advice and that of StuartR.

              Can I push my luck and ask a further question?

              The routine for automatically calculating a future date uses today’s date as the basis for the calculation of the future date. Is it possible to run the routine in a document (in the way I am using it, as previously explained), so that the future dates are calculated from some other past date? In other words, can I get the future timetable to run, not from today’s date (the date the letter is generated amd printed), but from some earlier date (that would be recorded at the start of the letter)?

              Many thanks.

              Brian

            • #881557

              Hi Brian,

              Another way to achive the same result would be to add an AutoOpen macro to your document, like:

              Sub AutoOpen()
              ActiveDocument.Fields.Update
              End Sub

              This will automatically update the fields in the body of the document each time you open it. Of course, if each recipient gets a different letter and/or you need to keep a record of the dates specified in each letter, you may also want to preserve the original dates. In that case, you might consider saving you document as a Word template and changing the four ‘DATE’ expressions to ‘CREATEDATE’.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #881402

              Even better! Many thanks.

              Brian

            • #881394

              You can set the Update Fields option in Tools > Options > Print. This will cause Word to update all fields every time it prints a document.

              StuartR

          • #881392

            Ah, yes. That does it! Thank you very much. I was hoping that there would be an automatic up-date, but obviously not (unless someone knows otherwise?).

            Thanks. A great site.

            Brian

        • #881384

          Did you update all the fields in the document? You can do this by typing Control-A to select the whole document and then F9 to update fields.

          StuartR

      • #881380

        This is a very impressive file. Thanks for creating it.

        If you have the time, could advise on what I am doing wrong when using the “Calculate a day, date, month and year, using n (43) weeks delay”, please?

        I have inserted this in 4 or 5 places in a standard letter which I will send to various people at various times. The letter effectively sets out a timetable for the recipients to do certain things on certain dates. I have adjusted the “n” delay in each of the 4 or 5 places so that the letter shows a number of different dates by which the recipients are to do something. The intended timetable is the same for every recipient (that is, the first action is 2 weeks after the date of the letter, the second action 3 weeks later, etc). The actual dates of the timetable are intended to up-date every time I send the letter – because the date of the letter will be different every time I use it.

        The problem is that the letter I set up yesterday has all the intended timetabled dates as I expected. But when I opened the same document today, the date field for the letter date updated to today’s date, but the timetabled dates in the body of the letter did not up-date by 1 day as expected. They stuck on the dates that were automatically generated yesterday.

        Can you assist, please?

        Many thanks.

        Brian

      • #904981

        Edited by Phil Rabichow to make the link clickable – see Help #19
        Hi Macropod

        http://www.wopr.com/cgi-bin/w3t/showflat.p…p;Number=249902%5B/url%5D

        There appears to be a discrepancy when calculations of “Calculate a day, date, month and year, using n (10) months delay” are carried out.
        If the date input is 1/12/04 and delay set to 4 or 6 months the day vaue is output at 30 instead of 1

        Any corrections to suggest or do I have to put my brain into gear to follow calculation method?

        Thanks and regards

        • #905256

          Hello Duncan,

          How are you doing the input? That example takes its date from the system clock. If I set mine to 1 December 2004, the 10 month delay correctly evaluates to 1 October 2005.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

        • #905257

          Hello Duncan,

          How are you doing the input? That example takes its date from the system clock. If I set mine to 1 December 2004, the 10 month delay correctly evaluates to 1 October 2005.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

        • #905370

          Hi Macropod

          I am using a {MERGEFIELD} for both the value of n and the date.
          Changing the calculation to :
          {SET Delay {MERGEFILED Duration}}
          {SET Date {MERGEFIELD EntryDate}}

          Does that make a difference ?

          The input to Fields is :
          Duration 6 or values to 12
          EntryDate dd/MM/yy

          Thanks and regards

          • #905613

            Hi Duncan,

            I think the problem you’re having is partly due to ‘DATE’ being a reserved field word. To get this to work, you’ll need to do something like:
            . Change all the DATE expressions in the existing field to ‘Mergedate’;
            . Add a field like ‘{SET MergeDate {MERGEFIELD EntryDate @ d/MM/yyyy}}’ just above or below the existing ‘{SET Delay 10}’ field; and
            . Use SET Delay {MERGEFIELD Duration}} instead of SET Delay {MERGEFILED Duration}} grin

            Cheers

            Cheers

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

            • #906804

              Hi Macropod,
              I think I am getting to understand the issues;
              A few examples when trying the script show a little of what happens
              1. Adding 3 months to 30/11/04 should give 29/2/05 but it tries to give 30/2/05
              2. Adding 4,6 etc months to 1/12/04 gives 30/4/05 or 30/6/05
              The same is true whether Mergefield is used or the original date input eg today at 30/11/04 + n=3
              The determination of the end of the months does not seem to work out correctly.
              For my purpose I need the following to apply:
              28=28; 29=29 or 28; 30=30 or 28/29; 31=31 or 30 or 28/29 each as applicable to the number of days available in the month. The issue is a legal purpose that requires the dates to be n months + 1day but where necessary the days of the month to truncate to the number of days available.
              Do you think this is really better done in excel rather than word? I would have preferred it to have been solely a word document.

              Hope you can help

              NB I appreciated the useful spell check
              thankyou

            • #907591

              Hi Duncan,

              Thanks for the feedback. I’ve been away for a few days, hence the delay in replying.

              It seems you’ve found an error in the coding of the SET dd field blush. Instead of the the existing code:
              {SET dd{=IF(({DATE @ d}>28)*(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0))=1,28,IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+({DATE @ d}>30)=1,30,{DATE @ d}))}}
              , it should have read:
              {SET dd{=IF(({DATE @ d}>28)*(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0))=1,29,IF(({DATE @ d}>29)*(mm=2)=1,28,IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+({DATE @ d}>30)>1,30,{DATE @ d})))}}

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #907592

              Hi Duncan,

              Thanks for the feedback. I’ve been away for a few days, hence the delay in replying.

              It seems you’ve found an error in the coding of the SET dd field blush. Instead of the the existing code:
              {SET dd{=IF(({DATE @ d}>28)*(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0))=1,28,IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+({DATE @ d}>30)=1,30,{DATE @ d}))}}
              , it should have read:
              {SET dd{=IF(({DATE @ d}>28)*(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0))=1,29,IF(({DATE @ d}>29)*(mm=2)=1,28,IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+({DATE @ d}>30)>1,30,{DATE @ d})))}}

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #907824

              Hi Macropod

              Sorry to make you blush but I believe you’ve cracked it.

              Excellent piece of work clever

              Interesting result though if you set delay to 5 and date at 31/11/04
              you get 4/4/1932 – guess it should be April 1st laugh

              Thanks and regards

              Duncan

            • #908083

              Hi Duncan,

              If you’re going to use invalid dates like 31/11/04, there’s no telling what you’ll get – I didn’t build in any validation code for that sort of thing. BTW, you should be aware that dd/mm/yy doesn’t mean the same as dd/mm/yyyy.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #908084

              Hi Duncan,

              If you’re going to use invalid dates like 31/11/04, there’s no telling what you’ll get – I didn’t build in any validation code for that sort of thing. BTW, you should be aware that dd/mm/yy doesn’t mean the same as dd/mm/yyyy.

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #907825

              Hi Macropod

              Sorry to make you blush but I believe you’ve cracked it.

              Excellent piece of work clever

              Interesting result though if you set delay to 5 and date at 31/11/04
              you get 4/4/1932 – guess it should be April 1st laugh

              Thanks and regards

              Duncan

            • #906805

              Hi Macropod,
              I think I am getting to understand the issues;
              A few examples when trying the script show a little of what happens
              1. Adding 3 months to 30/11/04 should give 29/2/05 but it tries to give 30/2/05
              2. Adding 4,6 etc months to 1/12/04 gives 30/4/05 or 30/6/05
              The same is true whether Mergefield is used or the original date input eg today at 30/11/04 + n=3
              The determination of the end of the months does not seem to work out correctly.
              For my purpose I need the following to apply:
              28=28; 29=29 or 28; 30=30 or 28/29; 31=31 or 30 or 28/29 each as applicable to the number of days available in the month. The issue is a legal purpose that requires the dates to be n months + 1day but where necessary the days of the month to truncate to the number of days available.
              Do you think this is really better done in excel rather than word? I would have preferred it to have been solely a word document.

              Hope you can help

              NB I appreciated the useful spell check
              thankyou

          • #905614

            Hi Duncan,

            I think the problem you’re having is partly due to ‘DATE’ being a reserved field word. To get this to work, you’ll need to do something like:
            . Change all the DATE expressions in the existing field to ‘Mergedate’;
            . Add a field like ‘{SET MergeDate {MERGEFIELD EntryDate @ d/MM/yyyy}}’ just above or below the existing ‘{SET Delay 10}’ field; and
            . Use SET Delay {MERGEFIELD Duration}} instead of SET Delay {MERGEFILED Duration}} grin

            Cheers

            Cheers

            Cheers,
            Paul Edstein
            [Fmr MS MVP - Word]

        • #905371

          Hi Macropod

          I am using a {MERGEFIELD} for both the value of n and the date.
          Changing the calculation to :
          {SET Delay {MERGEFILED Duration}}
          {SET Date {MERGEFIELD EntryDate}}

          Does that make a difference ?

          The input to Fields is :
          Duration 6 or values to 12
          EntryDate dd/MM/yy

          Thanks and regards

      • #904982

        Edited by Phil Rabichow to make the link clickable – see Help #19
        Hi Macropod

        http://www.wopr.com/cgi-bin/w3t/showflat.p…p;Number=249902%5B/url%5D

        There appears to be a discrepancy when calculations of “Calculate a day, date, month and year, using n (10) months delay” are carried out.
        If the date input is 1/12/04 and delay set to 4 or 6 months the day vaue is output at 30 instead of 1

        Any corrections to suggest or do I have to put my brain into gear to follow calculation method?

        Thanks and regards

      • #907400

        Hi there,

        I just sent this PM to Macropod but I think possibly others could benefit by it is as well:

        [indent]


        Hi there,

        First off I wanted to thank you personally for such an awesome macro as it’s a lifesaver. I do have a question regarding if a feature I am looking for with your macro.

        I am using just the portion of your macro to insert a date other than today (found here: http://www.gmayor.com/insert_a_date_other_than_today.htm) but what I really would like is the ability to just have it so that if I use the other date than today macro in my header that I can just have it specifically insert the date plus one day only (so if I did it today it would be December 2nd, tomorrow December 3rd, and so forth) and then also to compliment this feature have it automatically update itself.

        The reason I ask is I help with a newsletter for each Sunday but I create it throughout the week but then print them on Saturday so I was hoping that I could have the macro so if I start creating the newsletter on today but then print it on Saturday it will still show December 5th not December 2nd (date plus one).

        If I have confused you please don’t hesitate to PM me back and I will try to clarify.

        Once again thanks so much again and keep up the good work.

        Regards from Canada

        Curtis M.


        [/indent]

        • #907477

          Hi Curtis:
          Welcome to the Lounge. You are right in posting this on the main board, rather than as a PM (see Rule 10). The fields in Macropod’s attachment are not macros, they are fields.

          The answer that I think you want is found on p.10 of Macropod’s document, “Interactively Calculate A Past Or Future Date”. That has an ASK field that will ask you for the future date (e.g. 5/12/2004) & the delay (here = 0).

          Alternatively, you could use a much simpler field. You could put in an ASK field that asks for the date, enter the date, & then simply use a REF field to enter the date. That date wouldn’t change.

          e.g. I put out a newsletter for our Brownie Troop & give the next meeting date. I have a bookmark called NextMeeting & an ASK field to ask me for the next meeting date. Then I use the following field:

          { IF { NextMeeting } = “” { ASK NextMeeting “When is the next meeting?” d “” } }{ IF { page } = { numpages } “Next Meeting: { REF NextMeeting @ “dddd, MMMM d, yyyy” * Charformat }” “” { NUMPAGES }{ NUMPAGES }}

          where the curly brackets are inserted by pressing Ctrl+F9, not typed. You could adapt this for your newsletter.
          Cheers,

          • #907639

            [indent]


            e.g. I put out a newsletter for our Brownie Troop & give the next meeting date. I have a bookmark called NextMeeting & an ASK field to ask me for the next meeting date. Then I use the following field:

            { IF { NextMeeting } = “” { ASK NextMeeting “When is the next meeting?” d “” } }{ IF { page } = { numpages } “Next Meeting: { REF NextMeeting @ “dddd, MMMM d, yyyy” * Charformat }” “” { NUMPAGES }{ NUMPAGES }}


            [/indent]

            Phil,

            I think this is the method I would like to use but unfortunately I’m a newbie when it comes to fields, bookmarks and the like.

            Would it be too much to ask if you could walk me through the process of creating a bookmark and field and whatever else is needed to replicate what you mentioned above.

            If we can call the bookmark Newsletter that would be best so that I can follow easier and as well for your information, the date is going to be in the format of December 5th, 2004 and it will appear on the header of the document.

            I appreciate your help.

            Regards

            Curtis

          • #907640

            [indent]


            e.g. I put out a newsletter for our Brownie Troop & give the next meeting date. I have a bookmark called NextMeeting & an ASK field to ask me for the next meeting date. Then I use the following field:

            { IF { NextMeeting } = “” { ASK NextMeeting “When is the next meeting?” d “” } }{ IF { page } = { numpages } “Next Meeting: { REF NextMeeting @ “dddd, MMMM d, yyyy” * Charformat }” “” { NUMPAGES }{ NUMPAGES }}


            [/indent]

            Phil,

            I think this is the method I would like to use but unfortunately I’m a newbie when it comes to fields, bookmarks and the like.

            Would it be too much to ask if you could walk me through the process of creating a bookmark and field and whatever else is needed to replicate what you mentioned above.

            If we can call the bookmark Newsletter that would be best so that I can follow easier and as well for your information, the date is going to be in the format of December 5th, 2004 and it will appear on the header of the document.

            I appreciate your help.

            Regards

            Curtis

            • #907712

              Hi Curtis:
              Actually, I like macropod’s suggestion of using a Fill-in field because you don’t have to insert a separate bookmark. The reason I didn’t use it is that I didn’t want to be prompted every time I opened & worked on the document. So I used an ASK field that I only updated when I wanted to, & used an IF field so that it only updated once on the last page. I’ve attached a sample template (without any graphics as an example). The fields would have to be modified for your purposes. Mine was a next meeting date & went in the footer on the last page only. Yours would be a date on the first page only, so your field would be

              {IF {page} = 1 “{REF Newsletter}” “”}

              You insert the bookmark Newsletter by going to Insert/Bookmark & entering the word “Newsletter” (no quotes) in the dialog box. Then you need a {SET} field to give it the date. If you press Alt+F9 in the attached template, you can see the field codes.

              Quite frankly, it seems to me that you only want to enter the date once & not have it change. I think it’s easy to just type the date, rather than 1) figure todays date, 2) calculate how many days to publication, 3) enter those values & update the field. I would have done that except I wanted the challenge. grin You might want to just use the Print Date or Print Date + 1 (if it is always printed Saturday & has the Sunday date).
              Hope this helps,

            • #907739

              Phil,

              You mentioned the following:

              [indent]


              You might want to just use the Print Date or Print Date + 1 (if it is always printed Saturday & has the Sunday date).


              [/indent]

              As well in your template you had the example in the header, however it did not include the +1 you were referring to. I tried putting a +1 in multiple places and updated the fields and still it did not work.

              If you could be so kind and update the field in the header of your template with the +1 you are referring to in your message so that I can just copy and paste it over to my newsletter template it would be greatly appreciated.

              As well, if I want to verify that the field works do I need to send the document to print (just an assumption based on the name of the field) to see if the header updates the date to tomorrows date?

              Your continued help is appreciated.

              RGDS

              Curtis

            • #908251

              Hi Curtis:
              Here is a way to use PrintDate plus one, if you want. Just use this code in place of the date in the header of my example, where the curly brackets are inserted by pressing Ctrl+F9, not typed. Also, I re-read your post & see that you want to use the ordinal format for the day of the month, & my attachment didn’t account for that. Note that there is no validation, so that if you print it on October 31st, it will say October 32nd.

              { PrintDate @ “MMMM” } { = { PrintDate @ “d” } + 1 * ordinal }, { PrintDate @ “yyyy” }

              Cheers,

            • #908282

              [indent]


              Also, I re-read your post & see that you want to use the ordinal format for the day of the month, & my attachment didn’t account for that. Note that there is no validation, so that if you print it on October 31st, it will say October 32nd.

              { PrintDate @ “MMMM” } { = { PrintDate @ “d” } + 1 * ordinal }, { PrintDate @ “yyyy” }


              [/indent]

              Phil,

              I assume that ordinal refers to the ending after the date such as nd, st[/i]. I didn’t even notice that I put that myself in my post as it is not necessary. Seeing that it is not necessary can I just delete the word ordinal and that is it?

              If not if you could please update the field once again. I hope that I am not becoming a nuisance as that is not my intention. It is nice to see a community on the Internet where newbies are not flamed to death.

              Your help is appreciated like always.

              RGDS

              Curtis

            • #908288

              Hi Curtis:
              Not a problem. Just remove the “* ordinal”. The * is a formatting switch. You can read more about them in Help by pressing F1 & searching for Switches, then General Switches.
              Cheers,

            • #908513

              Phil,

              Great thanks

              Without the ordinal switch will it still say for example if Saturday is January 31 then say January 32? If so, do you know of any way that it can actually change to the next calendar day as I am sure that this might occur sometime down the road (checked and would occur in April 05 and December 05).

              Thanks again…

              Curtis

            • #908660

              Hi Curtis,

              If you want a ‘proper’ date calculation that takes account of month changes, you’ll need to use something like the ‘Calculate a Stepped Date’ or ‘Interactively Calculate A Past Or Future Date’ examples in the Date Calc document.

              Due to the length of this thread, please post any further discussions on this topic in the thread started at post 432773

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #908661

              Hi Curtis,

              If you want a ‘proper’ date calculation that takes account of month changes, you’ll need to use something like the ‘Calculate a Stepped Date’ or ‘Interactively Calculate A Past Or Future Date’ examples in the Date Calc document.

              Due to the length of this thread, please post any further discussions on this topic in the thread started at post 432773

              Cheers

              Cheers,
              Paul Edstein
              [Fmr MS MVP - Word]

            • #908664

              The calculations have nothing to do with the ordinal switch; that merely controls the formatting. If you want the next day every time you print the document, you’ll have to use the fields that macropod put in his date calculation document. You will find it in his document under “Calculate a day, date, month and year, using n (301) days delay”. You can copy the nested field into your document template, view field codes (Alt+F9), change the 301 to 1, change the word “Date” to “PrintDate”.
              Cheers,

            • #908665

              The calculations have nothing to do with the ordinal switch; that merely controls the formatting. If you want the next day every time you print the document, you’ll have to use the fields that macropod put in his date calculation document. You will find it in his document under “Calculate a day, date, month and year, using n (301) days delay”. You can copy the nested field into your document template, view field codes (Alt+F9), change the 301 to 1, change the word “Date” to “PrintDate”.
              Cheers,

            • #908289

              Hi Curtis:
              Not a problem. Just remove the “* ordinal”. The * is a formatting switch. You can read more about them in Help by pressing F1 & searching for Switches, then General Switches.
              Cheers,

            • #908283

              [indent]


              Also, I re-read your post & see that you want to use the ordinal format for the day of the month, & my attachment didn’t account for that. Note that there is no validation, so that if you print it on October 31st, it will say October 32nd.

              { PrintDate @ “MMMM” } { = { PrintDate @ “d” } + 1 * ordinal }, { PrintDate @ “yyyy” }


              [/indent]

              Phil,

              I assume that ordinal refers to the ending after the date such as nd, st[/i]. I didn’t even notice that I put that myself in my post as it is not necessary. Seeing that it is not necessary can I just delete the word ordinal and that is it?

              If not if you could please update the field once again. I hope that I am not becoming a nuisance as that is not my intention. It is nice to see a community on the Internet where newbies are not flamed to death.

              Your help is appreciated like always.

              RGDS

              Curtis

            • #908252

              Hi Curtis:
              Here is a way to use PrintDate plus one, if you want. Just use this code in place of the date in the header of my example, where the curly brackets are inserted by pressing Ctrl+F9, not typed. Also, I re-read your post & see that you want to use the ordinal format for the day of the month, & my attachment didn’t account for that. Note that there is no validation, so that if you print it on October 31st, it will say October 32nd.

              { PrintDate @ “MMMM” } { = { PrintDate @ “d” } + 1 * ordinal }, { PrintDate @ “yyyy” }

              Cheers,

            • #907740

              Phil,

              You mentioned the following:

              [indent]


              You might want to just use the Print Date or Print Date + 1 (if it is always printed Saturday & has the Sunday date).


              [/indent]

              As well in your template you had the example in the header, however it did not include the +1 you were referring to. I tried putting a +1 in multiple places and updated the fields and still it did not work.

              If you could be so kind and update the field in the header of your template with the +1 you are referring to in your message so that I can just copy and paste it over to my newsletter template it would be greatly appreciated.

              As well, if I want to verify that the field works do I need to send the document to print (just an assumption based on the name of the field) to see if the header updates the date to tomorrows date?

              Your continued help is appreciated.

              RGDS

              Curtis

            • #907713

              Hi Curtis:
              Actually, I like macropod’s suggestion of using a Fill-in field because you don’t have to insert a separate bookmark. The reason I didn’t use it is that I didn’t want to be prompted every time I opened & worked on the document. So I used an ASK field that I only updated when I wanted to, & used an IF field so that it only updated once on the last page. I’ve attached a sample template (without any graphics as an example). The fields would have to be modified for your purposes. Mine was a next meeting date & went in the footer on the last page only. Yours would be a date on the first page only, so your field would be

              {IF {page} = 1 “{REF Newsletter}” “”}

              You insert the bookmark Newsletter by going to Insert/Bookmark & entering the word “Newsletter” (no quotes) in the dialog box. Then you need a {SET} field to give it the date. If you press Alt+F9 in the attached template, you can see the field codes.

              Quite frankly, it seems to me that you only want to enter the date once & not have it change. I think it’s easy to just type the date, rather than 1) figure todays date, 2) calculate how many days to publication, 3) enter those values & update the field. I would have done that except I wanted the challenge. grin You might want to just use the Print Date or Print Date + 1 (if it is always printed Saturday & has the Sunday date).
              Hope this helps,

        • #907478

          Hi Curtis:
          Welcome to the Lounge. You are right in posting this on the main board, rather than as a PM (see Rule 10). The fields in Macropod’s attachment are not macros, they are fields.

          The answer that I think you want is found on p.10 of Macropod’s document, “Interactively Calculate A Past Or Future Date”. That has an ASK field that will ask you for the future date (e.g. 5/12/2004) & the delay (here = 0).

          Alternatively, you could use a much simpler field. You could put in an ASK field that asks for the date, enter the date, & then simply use a REF field to enter the date. That date wouldn’t change.

          e.g. I put out a newsletter for our Brownie Troop & give the next meeting date. I have a bookmark called NextMeeting & an ASK field to ask me for the next meeting date. Then I use the following field:

          { IF { NextMeeting } = “” { ASK NextMeeting “When is the next meeting?” d “” } }{ IF { page } = { numpages } “Next Meeting: { REF NextMeeting @ “dddd, MMMM d, yyyy” * Charformat }” “” { NUMPAGES }{ NUMPAGES }}

          where the curly brackets are inserted by pressing Ctrl+F9, not typed. You could adapt this for your newsletter.
          Cheers,

        • #907613

          Hi Curtis,

          Phil’s already answered much of your query, but there are two other options you might consider:
          1. Use a FILLIN field (eg {FILLIN “Newsletter Date?”}) to prompt you for the date. This will automatically prompt you for the date every time you open the document, and you don’t need to resort to REF fields to generate the output. It will also prompt you at print time if you have ‘Update Fields’ checked under Tools|Options|Print.
          2. Use the field example found under ‘Calculate a Stepped Date’, adjusted to suit your newsletter date requirements. This filed will auto-update without prompting.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

        • #907614

          Hi Curtis,

          Phil’s already answered much of your query, but there are two other options you might consider:
          1. Use a FILLIN field (eg {FILLIN “Newsletter Date?”}) to prompt you for the date. This will automatically prompt you for the date every time you open the document, and you don’t need to resort to REF fields to generate the output. It will also prompt you at print time if you have ‘Update Fields’ checked under Tools|Options|Print.
          2. Use the field example found under ‘Calculate a Stepped Date’, adjusted to suit your newsletter date requirements. This filed will auto-update without prompting.

          Cheers

          Cheers,
          Paul Edstein
          [Fmr MS MVP - Word]

      • #907401

        Hi there,

        I just sent this PM to Macropod but I think possibly others could benefit by it is as well:

        [indent]


        Hi there,

        First off I wanted to thank you personally for such an awesome macro as it’s a lifesaver. I do have a question regarding if a feature I am looking for with your macro.

        I am using just the portion of your macro to insert a date other than today (found here: http://www.gmayor.com/insert_a_date_other_than_today.htm) but what I really would like is the ability to just have it so that if I use the other date than today macro in my header that I can just have it specifically insert the date plus one day only (so if I did it today it would be December 2nd, tomorrow December 3rd, and so forth) and then also to compliment this feature have it automatically update itself.

        The reason I ask is I help with a newsletter for each Sunday but I create it throughout the week but then print them on Saturday so I was hoping that I could have the macro so if I start creating the newsletter on today but then print it on Saturday it will still show December 5th not December 2nd (date plus one).

        If I have confused you please don’t hesitate to PM me back and I will try to clarify.

        Once again thanks so much again and keep up the good work.

        Regards from Canada

        Curtis M.


        [/indent]

    Viewing 0 reply threads
    Reply To: Reply #754693 in Word Date Calculation Tutorial (v2.85)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information:




    Cancel