Results 1 to 15 of 15
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Field for today's date plus x days (95)

    Hi

    I want to insert a field into a document to give today's date plus x days. I've tried {={date}+18} for example, but that gives me 18.

    Any ideas?
    Dale

  2. #2
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Field for today's date plus x days (95)

    Hi Dale,

    I'll bet you didn't try:
    { QUOTE "{ SET Delay "18" }{ SET "DaysInMonth" { IF { CREATEDATE @ "MM" } <> 2 { = round(30.575*{ CREATEDATE @ "MM" },0)-ROUND(30.575*{ = { CREATEDATE @ "MM" } -1 },0) }{ IF { = MOD({ CREATEDATE @"yy" }, 4 ) } > 0 "28" "29" } } }{ SET "NextMonth" { IF { CREATEDATE @ "MM" } = 12 "1/97" "{ = { CREATEDATE @ "MM" } + 1 }/97 } }{ IF { = { REF Delay } + { CREATEDATE @ "dd" } } <= { DaysInMonth }{ CREATEDATE @ "MMMM { = { REF Delay} + { CREATEDATE @ "dd" } }, yyyy"}{ QUOTE { NextMonth @ "MMMM" } { = { REF Delay } + { CREATEDATE @ "dd" } - { DaysInMonth } }, { IF { } CREATEDATE @ "MM" } <> 12 { CREATEDATE @ "yyyy" }{ CREATEDATE @ "{ = 1 + { CREATEDATE @ "yyyy" } # "xxxx" }" } } } }" }
    <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    I don't recommend your attempting to type this at home! You can download a document with the above field in it (except it has 14 days which you could change) and/or link to the (WordBasic) macro that produced it by going to <A target="_blank" HREF=http://addbalance.com/word/datefields2.htm> Calculated dates in Word</A> (addbalance.com/word/datefields2.htm).
    Charles Kyle Kenyon
    Madison, Wisconsin

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Funny enough, you're right, Chas.

  4. #4
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Ahem,

    Don't take this wrong. I mean, far be it from me to throw any water the sizzle of that prodigious t-bone-like construction from Charles. But, gee wiz... There is another way.

    Selection.Text = Format(activedocument.BuiltInDocumentProperties("C reation Date") + 14, "MMMM d, YYYY")
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  5. #5
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Thanks, Kevin.

    I was actually after a field (rather than a macro), which is why Charles offered The Brute.

    Thanks for the suggestion
    Dale

  6. #6
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 Posts

    Re: Field for today's date plus x days (95)

    Ah, a former APLer...then, you'd know that writing a date+18 in APL is just that date+18. None of this nonsense.

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    ... and with a bit of luck, you could get your whole program on one line. Those were the days ... <img src=/S/sigh.gif border=0 alt=sigh width=15 height=15>

  8. #8
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    La Jolla, CA
    Posts
    1,468
    Thanks
    30
    Thanked 61 Times in 57 Posts

    Re: Field for today's date plus x days (95)

    Well, you could; but, that was really bad coding style.

  9. #9
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Field for today's date plus x days (95)

    Chris Woodman just updated his calculated date field generator. You can find it on his site at <A target="_blank" HREF=http://www.chriswoodman.co.uk/Utilities.htm> Utilities</A>. Those of you into customization and VBA might want to check out his Keyboard Shortcut organizer, Document Variable Viewer, and Setup Change utilities, too.
    Charles Kyle Kenyon
    Madison, Wisconsin

  10. #10
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Dale,

    Did you ever get this resolved?

    I just figured this out:

    { Date @ "D" } + 14

    ...for what its worth. I needed this. Thought I'd pass it on...
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  11. #11
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Thanks, Kevin.

    However, { Date @ "D" } + 14 only works if the date is in the first part of the month. Which is why Chas proposed The Brute, as follows:

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

    Ugly, eh! (But it seems to work, although I must admit I haven't worked out how to exhaustively test it yet.

    Thanks for your help
    Dale

  12. #12
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Ok, I get it.

    I put that brute in a doc. Wow, what a lug. The screen flickers for about 10 seconds and then you get field value.

    You're not really using that are you???
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  13. #13
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Wellington, Wellington, New Zealand
    Posts
    378
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    Hi Kevin

    I don't get any "flicker".

  14. #14
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    You are right on with your assessment of field codes. Besides being inadequate in Word, they are non-existant in Publisher -- still not a very serious product if you ask me.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  15. #15
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Field for today's date plus x days (95)

    I'm learning more as the seconds tick by.

    Charles referred to Chris Woodman's utility. I downloaded it and tried it . It works very nicely and I don't get the weird updating flicker that I got from the Brute -- but the Brute was obvioulsy created with Chris' utility.

    Not sure this is the answer for me (I put my "delayed" date calc in code; but that has it's problems too).
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •