• Calculated Dates in a Word Document

    Author
    Topic
    #2425104

    I have seen a number of posts on the subject of calculated dates, but nothing quite does what I am looking for, they all seem based on the current date.

    I am trying to create an itinerary document covering quite a few days.

    Header – Day 1 – Date

    Header – Day 2 – Date+1

    etc. I can get the Day 1, Day 2 etc from a standard Style. But I don’t know when the starting date will be. So I want to put the starting date in text form into the Day 1 header and then have subsequent headers increment the date.

    As I change the first day, I want all the other days to update. A bit difficult to describe, but the outcome should be something like this:

    Day 1 - Monday, 4th April    <------ Typed in
    Blah Blah Blah
    Day 2 - Tuesday, 5th April   <------- Calculated from Day 1
    Blah Blah Blah
    Day 3 - Wednesday, 6th April <-----Calculated from Day 1
    Blah Blah Blah

    etc

    When I change Day 1, I want the other dates to be re-calculated.

    Any ideas folks?

    PGB99

     

    Viewing 5 reply threads
    Author
    Replies
    • #2425142

      Eileen’s Lounge WORD Forum

      IF you can’t get a proper (presumed) macro created here I recommend HansV in the Word Forum of Eileen’s Lounge. This principle is easy with Excel numbers but seems a real challenge with Word and dates.

      W10 Pro 22H2 / Hm-Stdnt Ofce '16 C2R / Macrium Pd vX / GP=2 + FtrU=Semi-Annual + Feature Defer = 1 + QU = 0

    • #2425380

      If you don’t want to use excel or word macros, you can use word field codes (sourced/adapted from http://www.gmayor.com/insert_a_date_other_than_today.htm) to get this…

      WordIncrementingDateExample

      Use the attached word file to get started. To see the field formulas used ALT+F9. When you’ve finished updating use ALT+F9 to go back to the results. To update the start date use F9 and enter the date as prompted – all other fields should update to reflect the new start date.

      The field formula for Day 1 is:

      WordIncrementingDateExampleDay1

      The field formula for Day 2 is:

      WordIncrementingDateExampleDay2-1

      The field formula for subsequent days is below. You can copy/paste to get as many days as you need but you will have to manually update the number shown at (2) to be one less than the number shown at (1). So Day 2 will add 1 at (2) as shown, Day 3 will add 2 at (2) etc.

      WordIncrementingDateExampleDay2

       

      1 user thanked author for this post.
      • #2691700

        Hi btbs,

        Thank you for the sample DOCX file, as I was searching high and low for a Field Code that can generate a date that’s 21 days ahead of the current date.

        Two quick questions:

        – I use a cloud-driven field servicing platform called ServiceM8, which allows for custom Word document templates to be used for things such as invoicing. The current Field Code I’m using displays in Word as dd-MMMM-yyyy (20 August 2024, for example), however when the document is uploaded into ServiceM8 it displays it as dd-M-yyyy (20/8/2024, for example). Is there something that can be changed with the Field Code to force ServiceM8 to display it as it shows in Word or, at the very least, display the date as dd-MM-yyyy (20/08/2024)?

        – Is there a way to modify the Field Code to incorporate ordinal numbering into the date output?

        Find attached a screenshot of he Field Code I’m using, which is set to display a date 21 days from the current date. I tried to copy and paste it into the message body, but we all know how Word is like when it comes to this sort of thing.

        Cheers

        Word-Field-Code-20240730

    • #2425391

      Great, that looks like what I need, but I don’t see the attached Word file, just PNGs of the code?

      • #2425402

        Yeah, I noticed I’d missed that. I’ve edited my previous post to include it.

    • #2425405

      Fantastic – Works a charm.

      I have no idea what the maths is doing to sort out month and year ends. I will try to understand it later.

      But it does exactly what I needed.

      Many thanks

      PGB99

       

    • #2720941

      Sorry, but there is no filed attached.

      • #2720951

        Anonymous posters can’t see attachments – software issue.

        If you register you can see / download attachments. Or go to the GMayor site.

        cheers, Paul

      • #2720979

        I know this is an old post, but I wanted to let any users reading this that there is a MUCH easier way to do what the OP requested without Field codes or macros and involves way less coding. It is much easier to use Excel formulas to perform these Date calculations and then embed those formulas into the Word document which will stay with the Word document as it is moved or copied. The screenshot below shows the Word document with the embedded Excel Worksheet. I also provide the Word document with the embedded worksheet for download. You may need to remove any security options to get the worksheet to function in the document.

        Embed-Worksheet

        DateChange

        HTH, Dana:))

    • #2721016

      I also provide the Word document with the embedded worksheet for download.

      Sorry, while that Word document does have an embedded worksheet for date changing, it was not the example I intended to post. Here is the example of a Word document doing what the OP requested.

      Change-Date

      HTH, Dana:))

    Viewing 5 reply threads
    Reply To: Calculated Dates in a Word Document

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

    Your information: