|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Inserting a formula to count 30 days before and after a date in WORD table
I can do this in Excel with ease but after a couple hours of online research, I can't figure out how to do this in Word 2010.
I have figured out it has to be done in a table, and if I'm correct, have named the cells correctly in my description below. I have attached a Word 2010 Docx. I want to add a date in the yellow box in this table. R2C1 In R2C2 I want a date to automatically appear that is 30 days Before R2C1 In R2C3 I need a date to automatically appear that is 30 days After R2C1 I would be very grateful for a solution, if there is one |
#2
|
|||
|
|||
This requires complex fields. Word is not built to do it easily.
See the Date Calculation Tutorial and download it. It should have the fields you want or something close enough you can easily modify them to meet your needs. Last edited by Charles Kenyon; 05-18-2020 at 11:16 AM. |
#3
|
|||
|
|||
Charles... Thank you for your help. I've read through your document several times and unfortunately, I'm not savvy enough with the underbelly of the language or the functionality of Word and was unable to figure this out. I am grateful for your assistance.
|
#4
|
|||
|
|||
Quote:
{QUOTE{SET Delay 14}{SET a{=INT((14-{DATE \@ M})/12)}}{SET b{={DATE \@ yyyy}+4800-a}}{SET c{={DATE \@ M}+12*a-3}}{SET d{DATE \@ d}}{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32045+Delay}}{SET e{=INT((4*(jd+32044)+3)/146097)}}{SET f{=jd+32044-INT(146097*e/4)}}{SET g{=INT((4*f+3)/1461)}}{SET h{=f-INT(1461*g/4)}}{SET i{=INT((5*h+2)/153)}}{SET dd{=h-INT((153*i+2)/5)+1}}{SET mm{=i+3-12*INT(i/10)}}{SET yy{=100*e+g-4800+INT(i/10)}}"{dd}-{mm}-{yy}" \@ "dddd, d MMMM yyyy"} Again, read the introductory material, do not try to type this thing. You want to copy a field from the page as a whole and modify it. Change Delay to 30 from 14. That will give you a Date 30 days from the current date. If you change later on "+Delay" to "-Delay" it will give you 30 days before the current date. |
#5
|
|||
|
|||
See also Calculated Dates in Microsoft Word using Fields or vba.
In the field solution if you put these fields in a template and use the CreateDate field instead of the Date field when a document is created based on the template, you could have the CreateDate field, itself, as the base date and your other two dates will calculate automatically. You may also want to look at http://gregmaxey.com/word_tip_pages/...ted_dates.html. As you may have gathered, this is not for the faint-at-heart. |
#6
|
|||
|
|||
It definitely is not. I again, thank you and will tackle this project again tomorrow. The short story is that I deliver a locked down Word document daily to people. There is a text form field in it where they have to manually type a date. Next to that, amid a sentence, are 2 more text fields. Hoping this process will end in those 2 fields auto-populating (30 days before and after) based on the users manual date entry. Your answers lead me to believe I don't need the table to accomplish this. I'll keep you posted, and thank you.
|
#7
|
|||
|
|||
I believe that you can use a bookmarked date, but I am not sure how. I think the DatePicker control could be crucial to getting the beginning date to be recognized.
|
#8
|
||||
|
||||
No, it doesn't need to be in a table, but the attached implementation of the field codes from my tutorial with your document maintains your table.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Tutorial link is missing
Quote:
|
#10
|
|||
|
|||
Quote:
It is one of the pinned threads in this forum! Microsoft Word Date Calculation Tutorial I will change the earlier posts. For those who have not registered in this forum, a copy is also on Graham Mayor's website. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Date field - future date calculation + only business days | neon4 | Word | 7 | 01-21-2016 02:21 PM |
How to count even exact date 90 days | redza | Excel | 1 | 09-17-2013 03:36 AM |
Word Count Formula | clau_dos | Word VBA | 1 | 08-27-2013 02:05 PM |
Make table cell active add date count date | MelHerndon | Word VBA | 3 | 01-21-2013 04:23 PM |
Inserting a date calculated from a table cell | theMikeD | Word | 2 | 09-11-2012 05:46 PM |