Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In WORD display the DATE of following month 2

Status
Not open for further replies.

vacant

Technical User
Aug 5, 2001
35
0
0
GB
Hello tekkies

I've just had a user ask me if, each time they open a particular batch of documents, they can display the month and year of the following month. I said "Sure, anything's possible!", but on getting back to my desk quickly realised I haven't got a clue how to do it

I took a wild guess with {IF {TIME \@ "MM"} = 12 "'January ' {TIME \@ "YYYY" + 1}" "{TIME \@ "MMMM" + 1} {TIME \@ "YYYY"}"}, but this just displays a big blank nothing

I'm hopeless with Word. Somebody please help, if you can...
 
This will get you the next month:
[tt]{ =Mod( {DATE \@ "M" },12)+1 }[/tt]
Note: the [tt]{DATE \@ "M" }[/tt] cannot be typed in, it must be inserted (Insert=>Field)

If you use this in conjunction with [tt]QUOTE[/tt] you should be able to make it work.

Hope this helps.
CMP

Instant programmer, just add coffee.
 
BLIMEY! I'd never have got that

Thanks to you both, and a big pink star to macropod for the fantastic link

{QUOTE{SET Delay = 1}{SET m"{=MOD({DATE \@ MM},12)+1}/0"}{SET y{={DATE \@ yyyy}+INT((Delay+{DATE \@ M}-1)/12)}}{m \@ MMMM}160{y}}

is what did it for me
 
Hi Vacant,

Having a document display the month and year of the following month each time it is opened is unusual - how would you know what date appeared on any letter that had been printed. More commonly, you'd want a template to insert a fixed date, based on the date the document created from it was first saved. For that you'd use a CREATEDATE field. The CREATEDATE field inserts the date the document was created, and remains unchanged unless the file is saved using File|Save As.

There are also two other variations on the DATE field that your client might be interested in:
· SAVEDATE
· PRINTDATE

The SAVEDATE field inserts the date the document was last saved, and updates whenever you save the document.

The PRINTDATE field inserts the date the document was last printed, and updates whenever you print the document.

Cheers
PS: The posted field code should have read:
{QUOTE{SET m"{=MOD({DATE \@ MM},12)+1}/0"}{SET y{={DATE \@ yyyy}+INT((1+{DATE \@ M}-1)/12)}}{m \@ MMMM}160{y}}

PPS: To use the 'Delay' variable correctly, you'd have to recode the field in your post to:
{QUOTE{SET Delay 1}{SET m"{=MOD({DATE \@ MM}+Delay-1,12)+1}/0"}{SET y{={DATE \@ yyyy}+INT((Delay+{DATE \@ M}-1)/12)}}{m \@ MMMM}160{y}}
 
Many thanks for the follow up, mr/mrs macropod. I've made a note of your amended code

It actually was a set of mail merge templates that I needed the above for - not documents as I mistakenly described them - so there won't be a problem with the resulting invoices showing the wrong date if they're subsequently re-opened.

Furthermore, your tutorial on is absolutely superb - I have it saved now on our IM&T dept drive so that we can all refer to it.

Sincerely grateful for your help
v.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top