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.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Word Date Calculation Tutorial (v2.85)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Word Date Calculation Tutorial (v2.85)
- This topic has 173 replies, 24 voices, and was last updated 17 years ago.
AuthorTopicWSPhil Rabichow
AskWoody LoungerMay 3, 2003 at 8:06 pm #386937Viewing 0 reply threadsAuthorReplies-
macropod
AskWoody_MVPApril 26, 2008 at 2:01 am #673318Attached 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] -
WSHansV
AskWoody Lounger -
WSlegalbear2001
AskWoody LoungerJuly 2, 2003 at 6:48 pm #690802Huloo – 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!
-
WSjscher2000
AskWoody LoungerJuly 2, 2003 at 9:10 pm #690827Sorry, 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…
-
macropod
AskWoody_MVPJuly 4, 2003 at 1:39 am #690890Hi 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] -
WSlegalbear2001
AskWoody LoungerJuly 3, 2003 at 5:18 pm #691017Dude, 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!!!
-
macropod
AskWoody_MVP -
WSvswearingen
AskWoody LoungerDecember 7, 2003 at 1:28 pm #754124Fabulous! 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 “”
-
macropod
AskWoody_MVPDecember 10, 2003 at 1:00 am #755204 -
WSvswearingen
AskWoody Lounger -
WSvswearingen
AskWoody Lounger -
macropod
AskWoody_MVPDecember 10, 2003 at 1:00 am #755205 -
WSvswearingen
AskWoody LoungerDecember 7, 2003 at 1:28 pm #754125Fabulous! 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 “”
-
-
-
-
-
WSBillCoan
AskWoody Lounger -
WSfburg
AskWoody LoungerDecember 8, 2003 at 2:21 pm #754476macropod,
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
-
WSHansV
AskWoody Lounger -
WSfburg
AskWoody LoungerDecember 8, 2003 at 2:53 pm #754506HansV,
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
-
WSjscher2000
AskWoody Lounger -
WSfburg
AskWoody LoungerDecember 9, 2003 at 10:37 pm #755180 -
WSfburg
AskWoody LoungerDecember 9, 2003 at 10:37 pm #755181 -
WSjscher2000
AskWoody Lounger -
macropod
AskWoody_MVPDecember 8, 2003 at 9:14 pm #754692Hi 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] -
WSfburg
AskWoody LoungerDecember 9, 2003 at 10:42 pm #755182hi 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.
Fred
-
WSfburg
AskWoody LoungerDecember 9, 2003 at 10:42 pm #755183hi 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.
Fred
-
macropod
AskWoody_MVPDecember 8, 2003 at 9:14 pm #754693Hi 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]
-
-
-
WSfburg
AskWoody LoungerDecember 8, 2003 at 2:53 pm #754507HansV,
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
-
WSHansV
AskWoody LoungerWSfburg
AskWoody LoungerDecember 8, 2003 at 2:21 pm #754477macropod,
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
WSAlanMiller
AskWoody Lounger-
macropod
AskWoody_MVP -
WSAlanMiller
AskWoody LoungerFebruary 11, 2004 at 10:57 pm #782966Macropod
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
. 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
-
WSBerylM
AskWoody LoungerFebruary 12, 2004 at 9:23 am #783115I 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
-
WSAlanMiller
AskWoody LoungerFebruary 12, 2004 at 11:28 am #783163Hi 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:
-
WSAlanMiller
AskWoody LoungerFebruary 12, 2004 at 11:28 am #783164Hi 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:
-
WSBerylM
AskWoody LoungerFebruary 12, 2004 at 9:23 am #783116I 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
-
-
-
WSAlanMiller
AskWoody LoungerFebruary 11, 2004 at 10:57 pm #782967Macropod
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
. 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
macropod
AskWoody_MVPWSAlanMiller
AskWoody LoungerWSjbrezina
AskWoody LoungerFebruary 12, 2004 at 1:46 pm #783232Wow–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.
-
WSmkeyser
AskWoody LoungerFebruary 12, 2004 at 9:17 pm #783545Instead 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
-
WSmkeyser
AskWoody LoungerFebruary 12, 2004 at 9:17 pm #783546Instead 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
WSjbrezina
AskWoody LoungerFebruary 12, 2004 at 1:46 pm #783233Wow–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.
WSTimNott
AskWoody LoungerMarch 7, 2004 at 11:53 am #795660I 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.-
WSPhil Rabichow
AskWoody LoungerMarch 7, 2004 at 7:40 pm #795747Hi 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, -
WSPhil Rabichow
AskWoody LoungerMarch 7, 2004 at 7:40 pm #795748Hi 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, -
macropod
AskWoody_MVPMarch 7, 2004 at 9:21 pm #795853Hi 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] -
WSTimNott
AskWoody LoungerMarch 8, 2004 at 8:23 am #795994Thanks 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 Dueor shorter in coarse VBA
ActiveDocument.Bookmarks(“duedate”).Select
Selection.TypeText Text:=Format(Date + 30, “d mmmm yyyy”)Tim
-
macropod
AskWoody_MVP -
WSpetermoran
AskWoody LoungerMarch 8, 2004 at 10:17 pm #796332Edited 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! -
WSpetermoran
AskWoody LoungerMarch 8, 2004 at 10:17 pm #796333Edited 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! -
WSTimNott
AskWoody LoungerMarch 10, 2004 at 10:54 am #797035Yes, 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?
-
macropod
AskWoody_MVPMarch 10, 2004 at 11:04 am #797041Hi 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] -
macropod
AskWoody_MVPMarch 10, 2004 at 11:04 am #797042Hi 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] -
WSTimNott
AskWoody LoungerMarch 10, 2004 at 10:54 am #797036Yes, 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?
-
macropod
AskWoody_MVP
-
-
-
WSTimNott
AskWoody LoungerMarch 8, 2004 at 8:23 am #795995Thanks 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 Dueor shorter in coarse VBA
ActiveDocument.Bookmarks(“duedate”).Select
Selection.TypeText Text:=Format(Date + 30, “d mmmm yyyy”)Tim
macropod
AskWoody_MVPMarch 7, 2004 at 9:21 pm #795854Hi 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]WSTimNott
AskWoody LoungerMarch 7, 2004 at 11:53 am #795661I 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.WSkleveck
AskWoody LoungerMarch 15, 2004 at 2:32 am #799011Are 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-
macropod
AskWoody_MVPMarch 15, 2004 at 10:05 am #799121Hi 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]
macropod
AskWoody_MVPMarch 15, 2004 at 10:05 am #799122Hi 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]WSkleveck
AskWoody LoungerMarch 15, 2004 at 2:32 am #799012Are 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,
kleveckWSdeslavender
AskWoody LoungerMay 20, 2004 at 8:15 am #829933Like, 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?
-
macropod
AskWoody_MVPMay 21, 2004 at 6:08 am #829976Hi 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)*2I’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] -
WSdeslavender
AskWoody LoungerMay 20, 2004 at 12:38 pm #830034Thanx. 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.
-
macropod
AskWoody_MVPMay 21, 2004 at 6:26 am #830442Hi 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] -
WSdeslavender
AskWoody LoungerMay 21, 2004 at 8:54 am #830484Thanx. 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.
-
macropod
AskWoody_MVPMay 22, 2004 at 9:17 am #831041Hi 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] -
macropod
AskWoody_MVPMay 22, 2004 at 9:17 am #831042Hi 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] -
WSdeslavender
AskWoody LoungerMay 21, 2004 at 8:54 am #830485Thanx. 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.
-
macropod
AskWoody_MVPMay 21, 2004 at 6:26 am #830443Hi 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]
-
-
-
WSdeslavender
AskWoody LoungerMay 20, 2004 at 12:38 pm #830035Thanx. 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.
macropod
AskWoody_MVPMay 21, 2004 at 6:08 am #829977Hi 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)*2I’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]WSdeslavender
AskWoody LoungerMay 20, 2004 at 8:15 am #829934Like, 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?
WSCarlito
AskWoody LoungerMay 31, 2004 at 9:34 am #834776Hi 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!
-
macropod
AskWoody_MVPMay 31, 2004 at 10:03 am #834794Hi 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] -
WSCarlito
AskWoody LoungerMay 31, 2004 at 9:26 pm #835155Many 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!
-
macropod
AskWoody_MVPJune 1, 2004 at 1:44 am #835205Hi 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] -
WSCarlito
AskWoody Lounger -
WSCarlito
AskWoody Lounger -
macropod
AskWoody_MVPJune 1, 2004 at 1:44 am #835206Hi 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]
-
-
-
WSCarlito
AskWoody LoungerMay 31, 2004 at 9:26 pm #835156Many 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!
macropod
AskWoody_MVPMay 31, 2004 at 10:03 am #834795Hi 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]WSCarlito
AskWoody LoungerMay 31, 2004 at 9:34 am #834777Hi 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!
WSZ-Man
AskWoody LoungerJune 28, 2004 at 7:25 pm #845560Thanks 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
{QUOTE19-03-2005 @ “dddd, d
-
WSjscher2000
AskWoody LoungerJune 28, 2004 at 9:01 pm #845615In 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.
-
WSjscher2000
AskWoody LoungerJune 28, 2004 at 9:01 pm #845616In 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.
-
macropod
AskWoody_MVPJuly 1, 2004 at 9:54 am #846549Hi 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]
macropod
AskWoody_MVPJuly 1, 2004 at 9:54 am #846550Hi 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]WSAlanMiller
AskWoody LoungerWSAlanMiller
AskWoody LoungerWSZ-Man
AskWoody LoungerJune 28, 2004 at 7:25 pm #845561Thanks 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
{QUOTE19-03-2005 @ “dddd, d
WSvfrdavid
AskWoody LoungerWSvfrdavid
AskWoody LoungerWSkoenp
AskWoody LoungerAugust 30, 2004 at 11:01 am #870313-
WSPhil Rabichow
AskWoody Lounger -
WSPhil Rabichow
AskWoody Lounger
WSkoenp
AskWoody LoungerAugust 30, 2004 at 11:01 am #870314WSBdoyle
AskWoody LoungerSeptember 25, 2004 at 7:17 am #881379This 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
-
WSStuartR
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
WSStuartR
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
macropod
AskWoody_MVPSeptember 25, 2004 at 9:30 pm #881556Hi 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 SubThis 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] -
WSBdoyle
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
WSBdoyle
AskWoody LoungerSeptember 28, 2004 at 9:33 am #882254I 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
-
WSPhil Rabichow
AskWoody Lounger -
WSBdoyle
AskWoody LoungerSeptember 28, 2004 at 7:20 pm #882513Hi 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
-
WSjscher2000
AskWoody LoungerSeptember 28, 2004 at 7:48 pm #882549Can 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.
-
WSBdoyle
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
WSjscher2000
AskWoody LoungerSeptember 28, 2004 at 7:48 pm #882550Can 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.
-
WSBdoyle
AskWoody LoungerSeptember 28, 2004 at 7:20 pm #882514Hi 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
-
WSPhil Rabichow
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
macropod
AskWoody_MVPSeptember 29, 2004 at 6:23 am #882741Hi 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] -
WSBdoyle
AskWoody Lounger -
WSBdoyle
AskWoody Lounger -
macropod
AskWoody_MVPSeptember 29, 2004 at 6:23 am #882742Hi 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] -
WSBdoyle
AskWoody Lounger -
WSPhil Rabichow
AskWoody Lounger -
WSPhil Rabichow
AskWoody Lounger -
WSBdoyle
AskWoody LoungerSeptember 28, 2004 at 9:33 am #882255I 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
-
macropod
AskWoody_MVPSeptember 25, 2004 at 9:30 pm #881557Hi 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 SubThis 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] -
WSBdoyle
AskWoody Lounger -
WSStuartR
AskWoody Lounger
-
-
-
WSBdoyle
AskWoody Lounger
WSStuartR
AskWoody LoungerWSBdoyle
AskWoody LoungerSeptember 25, 2004 at 7:17 am #881380This 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
WSDuncan McDonald
AskWoody LoungerNovember 27, 2004 at 9:48 pm #904981Edited by Phil Rabichow to make the link clickable – see Help #19
Hi Macropodhttp://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 1Any corrections to suggest or do I have to put my brain into gear to follow calculation method?
Thanks and regards
-
macropod
AskWoody_MVP -
macropod
AskWoody_MVP -
WSDuncan McDonald
AskWoody LoungerNovember 26, 2004 at 1:25 pm #905370Hi 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/yyThanks and regards
-
macropod
AskWoody_MVPNovember 27, 2004 at 12:40 am #905613Hi 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}}Cheers
Cheers
Cheers,
Paul Edstein
[Fmr MS MVP - Word] -
WSDuncan McDonald
AskWoody LoungerNovember 30, 2004 at 1:09 pm #906804Hi 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
-
macropod
AskWoody_MVPDecember 1, 2004 at 8:57 pm #907591Hi 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
. 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] -
macropod
AskWoody_MVPDecember 1, 2004 at 8:57 pm #907592Hi 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
. 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] -
WSDuncan McDonald
AskWoody Lounger -
macropod
AskWoody_MVPDecember 2, 2004 at 7:52 pm #908083 -
macropod
AskWoody_MVPDecember 2, 2004 at 7:52 pm #908084 -
WSDuncan McDonald
AskWoody Lounger -
WSDuncan McDonald
AskWoody LoungerNovember 30, 2004 at 1:09 pm #906805Hi 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
-
-
-
macropod
AskWoody_MVPNovember 27, 2004 at 12:40 am #905614Hi 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}}Cheers
Cheers
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
WSDuncan McDonald
AskWoody LoungerNovember 26, 2004 at 1:25 pm #905371Hi 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/yyThanks and regards
WSDuncan McDonald
AskWoody LoungerNovember 27, 2004 at 9:48 pm #904982Edited by Phil Rabichow to make the link clickable – see Help #19
Hi Macropodhttp://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 1Any corrections to suggest or do I have to put my brain into gear to follow calculation method?
Thanks and regards
WSCurtisMinBC
AskWoody LoungerDecember 1, 2004 at 4:47 pm #907400Hi 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]
-
WSPhil Rabichow
AskWoody LoungerDecember 1, 2004 at 6:27 pm #907477Hi 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, -
WSCurtisMinBC
AskWoody LoungerDecember 1, 2004 at 10:21 pm #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
-
WSCurtisMinBC
AskWoody LoungerDecember 1, 2004 at 10:21 pm #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
-
WSPhil Rabichow
AskWoody LoungerDecember 2, 2004 at 1:20 am #907712Hi 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.
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, -
WSCurtisMinBC
AskWoody LoungerDecember 2, 2004 at 7:15 am #907739Phil,
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
-
WSPhil Rabichow
AskWoody LoungerDecember 3, 2004 at 1:19 am #908251Hi 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,
-
WSCurtisMinBC
AskWoody LoungerDecember 3, 2004 at 4:23 am #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
-
WSPhil Rabichow
AskWoody Lounger -
WSCurtisMinBC
AskWoody LoungerDecember 3, 2004 at 3:55 pm #908513Phil,
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
-
macropod
AskWoody_MVPDecember 3, 2004 at 8:37 pm #908660Hi 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] -
macropod
AskWoody_MVPDecember 3, 2004 at 8:37 pm #908661Hi 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] -
WSPhil Rabichow
AskWoody LoungerDecember 3, 2004 at 8:42 pm #908664The 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, -
WSPhil Rabichow
AskWoody LoungerDecember 3, 2004 at 8:42 pm #908665The 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, -
WSPhil Rabichow
AskWoody Lounger -
WSCurtisMinBC
AskWoody LoungerDecember 3, 2004 at 4:23 am #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
-
WSPhil Rabichow
AskWoody LoungerDecember 3, 2004 at 1:19 am #908252Hi 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,
-
WSCurtisMinBC
AskWoody LoungerDecember 2, 2004 at 7:15 am #907740Phil,
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
-
WSPhil Rabichow
AskWoody LoungerDecember 2, 2004 at 1:20 am #907713Hi 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.
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,
-
-
WSPhil Rabichow
AskWoody LoungerDecember 1, 2004 at 6:27 pm #907478Hi 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,macropod
AskWoody_MVPDecember 1, 2004 at 9:18 pm #907613Hi 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]macropod
AskWoody_MVPDecember 1, 2004 at 9:18 pm #907614Hi 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]WSCurtisMinBC
AskWoody LoungerDecember 1, 2004 at 4:47 pm #907401Hi 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 -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
26 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
1 hour, 21 minutes ago -
Auto Time Zone Adjustment
by
wadeer
4 hours, 55 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
2 hours, 35 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
1 hour, 48 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
54 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
1 hour, 46 minutes ago -
Apps included with macOS
by
Will Fastie
2 hours, 36 minutes ago -
Xfinity home internet
by
MrJimPhelps
1 hour, 41 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
6 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 2 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
1 day, 5 hours ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
9 hours, 11 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
1 hour, 36 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
1 day, 22 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
1 day, 13 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
2 days, 1 hour ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
1 day, 17 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 1 hour ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
3 hours, 6 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
2 days, 10 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
2 days, 7 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
1 day, 21 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
1 day, 8 hours ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
21 hours, 22 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
3 days, 3 hours ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
3 days, 3 hours ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
2 days, 16 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
3 days, 11 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.