#1
|
|||
|
|||
Automatically update year + 1
Hi all,
I have been attempting to use the calculated date tutorial for the first time. I have a date displayed in the Word doc by default and need it to default to today's date + 1 year. In the tutorial, I see: Code:
{QUOTE {SET Delay 1} {DATE \@ MMMM}160{={DATE \@ yyyy}+Delay}} (I realize I could have played with this more, and I do normally enjoy solving things myself, but I'm a medical social worker serving individuals who are immunocompromised and hoping someone won't mind giving me a one-time pass in helping with a solution here to save some time given the pandemic. Thank you so much for your understanding and assistance.) |
#2
|
|||
|
|||
What I get with this code is May 2021. Are you getting May 2020?
Did you press F9 with the entire code selected after inserting it? Did you read the introductory material in the tutorial? It is important. The following gives me May 4, 2021. { Date \@ "MMMM d" }, { = { DATE \@ yyyy } + 1 } I do not understand the 160 in Paul's but am guessing it has to do with a 360 day accounting year. In general the math for a year is much simpler than for month and day. Paul is a regular here and will likely explain all. |
#3
|
|||
|
|||
Hi there,
I copy and paste the source code from Paul's doc, after hitting Alt+F9 to toggle the field codes on. I see that Ctrl + F9 would allow me to introduce a field as well, but I think pasting the source code in while field codes are toggled on should work? The output I get is March 38536, which I don't understand, except that maybe it's one of the other calendars mentioned in the intro. I'd like the output to be 4/5/2021 (1 year from today's date), so I tried changing the date configuration as follows: Code:
{QUOTE {SET Delay 1} { Date \@ d/M/yyyy + 1 } (p.s. The 160 in Paul's original inserts a nonbreaking space, according to the instructions.) |
#4
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
The code you started with has no day code.
{QUOTE {SET Delay 1} {DATE \@ MMMM}160{={DATE \@ yyyy}+Delay}} Try instead: {QUOTE {SET Delay 1} {DATE \@ "d/MMMM/"}{={DATE \@ yyyy}+Delay}} Since you are editing the DATE field, when you toggle it back to results, those results are not changed until the field is updated. That is why both of us have told you that you need to press the F9 key to update the field. Yes, Ctrl+F9 lets you insert a blank field to type in. |
#6
|
||||
|
||||
That simply won't work for leap years (i.e. Feb 29). The tutorial has field coding to address the leap year issue.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Paul, you are correct.
He started with the wrong formula from DateCalc. He was using the one for Month and Year but wanted to include the day. That is also found in your work. Here it is formatted the way he wants it: Code:
{QUOTE {SET Delay 1} {SET od{DATE \@ d}} {SET oy{DATE \@ yyyy}} {SET mm{DATE \@ M}} {SET ld{=(mm=2)*(od=28+((MOD(oy,4)=0)+(MOD(oy,400)=0)-(MOD(oy,100)=0)))}} {SET yy{=oy+Delay}} {SET dd{=ld*(28+(mm=2)*((MOD(yy,4)=0)+(MOD(yy,400)=0)-(MOD(yy,100)=0)))+od*(1-ld)}} "{mm}-{dd}-{yy}" \@ "M/d/yyyy"} This is formatted for US not European date format. Here is a document containing the field. |
#8
|
|||
|
|||
Thank you Paul and Charles. I really appreciate the assistance.
I'll have to go through the tutorial more closely, because even when I paste in the final code below, select it, and hit F9, I was still doing something wrong (or not doing something right!) because I believe the output was blank. In any case, you helped me get a form together quickly that will help our clients, which is quite helpful during this time. Thank you again. |
#9
|
||||
|
||||
Without actually seeing your implementation in a document, it can be difficult for anyone to diagnose the issue. Can you attach a document to a post with your implementation of the field (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#10
|
|||
|
|||
Quote:
Then do take the time to review the introductory material in the tutorial. Among other things, the fields in it are sensitive to your regional date settings. |
Tags |
future date, year |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to search for a specific year from a table with year range? | Wii | Excel | 0 | 05-05-2015 12:40 PM |
How to calculate a rolling year-to-date percentage by quarter as the year progresses | sleake | Excel Programming | 2 | 04-23-2015 11:51 AM |
Networkdays per fiscal year in a 6 year range | jabnm | Excel | 1 | 10-16-2014 11:51 AM |
Year to Year in Fillable form | Lara | Word | 1 | 04-09-2013 03:19 PM |
Creative Ways for a year-to-year comparison??? | ridonkulous5 | Excel | 1 | 03-23-2011 04:49 PM |