Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-04-2020, 09:07 AM
PrincessApril PrincessApril is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Competent Performer
Automatically update year + 1
 
Join Date: Nov 2019
Posts: 102
PrincessApril is on a distinguished road
Default 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}}
When I insert this into the Field Code after hitting Alt+F9, the date still reads as today's date. I don't quite see what I'd change given that the delay+1 seems set>



(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.)
Reply With Quote
  #2  
Old 05-04-2020, 11:34 AM
Charles Kenyon Charles Kenyon is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #3  
Old 05-04-2020, 01:51 PM
PrincessApril PrincessApril is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Competent Performer
Automatically update year + 1
 
Join Date: Nov 2019
Posts: 102
PrincessApril is on a distinguished road
Default

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 }
But the output now in my document is just blank.

(p.s. The 160 in Paul's original inserts a nonbreaking space, according to the instructions.)
Reply With Quote
  #4  
Old 05-04-2020, 03:33 PM
macropod's Avatar
macropod macropod is offline Automatically update year + 1 Windows 7 64bit Automatically update year + 1 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by PrincessApril View Post
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}}
When I insert this into the Field Code after hitting Alt+F9, the date still reads as today's date. I don't quite see what I'd change given that the delay+1 seems set
Alt+F9 doesn't refresh the field; it simply toggles the field code display on/off. Select the field and press F9.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 05-04-2020, 04:39 PM
Charles Kenyon Charles Kenyon is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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.
Reply With Quote
  #6  
Old 05-04-2020, 04:57 PM
macropod's Avatar
macropod macropod is offline Automatically update year + 1 Windows 7 64bit Automatically update year + 1 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Charles Kenyon View Post
Try instead:
{QUOTE {SET Delay 1} {DATE \@ "d/MMMM/"}{={DATE \@ yyyy}+Delay}}
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]
Reply With Quote
  #7  
Old 05-04-2020, 07:51 PM
Charles Kenyon Charles Kenyon is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

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"}
Today, it returns 5/4/2021
This is formatted for US not European date format.
Here is a document containing the field.
Attached Files
File Type: docx DateOneYearLater.docx (48.6 KB, 8 views)
Reply With Quote
  #8  
Old 05-07-2020, 04:22 PM
PrincessApril PrincessApril is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Competent Performer
Automatically update year + 1
 
Join Date: Nov 2019
Posts: 102
PrincessApril is on a distinguished road
Default

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.
Reply With Quote
  #9  
Old 05-07-2020, 04:25 PM
macropod's Avatar
macropod macropod is offline Automatically update year + 1 Windows 7 64bit Automatically update year + 1 Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #10  
Old 05-07-2020, 04:38 PM
Charles Kenyon Charles Kenyon is offline Automatically update year + 1 Windows 10 Automatically update year + 1 Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,083
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by PrincessApril View Post
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.
Did you try the sample I posted? Try pasting that into your document.
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.
Reply With Quote
Reply

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
Automatically update year + 1 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

Other Forums: Access Forums

All times are GMT -7. The time now is 06:42 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft