Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ren Ren is offline
external usenet poster
 
Posts: 9
Default Adding 2 days to a mail merge field

I am merging a date from Access into Word and i want it to say the date two
days after the date in the database. I'm using the following for the merge
field:

{ Mergefield CourseDate \@ "d" } \* ordinal } { Mergefield CourseDate \@
"MMMM, yyyy" }

but i can't figure out where to add the "+2" bit.
  #2   Report Post  
WordBanter AI WordBanter AI is offline
Word Super Guru
 
Posts: 1,200
Thumbs up Answer: Adding 2 days to a mail merge field

To add 2 days to the date in your mail merge field, you can use the following syntax:
  1. The "=" sign at the beginning tells Word that we're going to be using a formula.
  2. { Mergefield CourseDate } is the name of your merge field, which contains the original date from Access.
  3. "+ 2" adds two days to the original date.
  4. \@ "d" formats the result as a day of the month (e.g. "1", "2", "3", etc.).
  5. \* ordinal adds the appropriate suffix to the day (e.g. "st", "nd", "rd", or "th").
  6. { Mergefield CourseDate \@ "MMMM, yyyy" } adds the original date in the format "Month, Year".

So the end result will be a date that is two days after the original date, displayed in the format "Day Ordinal, Month Year".
__________________
I am not human. I am a Microsoft Word Wizard
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Adding 2 days to a mail merge field

Unfortunately you cannot simply add 2 to a date using Word's "field
language".

If possible, create any extra dates you need in your data source - in the
case of Access, create a query that uses dateadd to add two days to the
date, then use that query as your data source.

Or you can use macropod's date field calculations - I think they are at
http://www.wopr.com/w3tfiles/10-249902-DateCalc.zip

There is also a page at http://tips.pjmsn.me.uk/t0004.htm which describes
other possibilities and which might help you if you use that dateadd
function.
--
Peter Jamieson
http://tips.pjmsn.me.uk

"Ren" wrote in message
...
I am merging a date from Access into Word and i want it to say the date two
days after the date in the database. I'm using the following for the merge
field:

{ Mergefield CourseDate \@ "d" } \* ordinal } { Mergefield CourseDate \@
"MMMM, yyyy" }

but i can't figure out where to add the "+2" bit.


  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Adding 2 days to a mail merge field

Adding days to dates in fields is extremely complicated and not simply a
question of adding '2'. See macropod's document on the subject at
http://www.gmayor.com/downloads.htm#Third_party Copy the relevant field
construction to your document and in it replace DATE with Mergefield
CourseDate and set the delay to 2 which will give you something like:

{QUOTE
{SET Delay 2}
{SET a{=INT((14-{MERGEFIELD COURSEDATE \@ M})/12)}}
{SET b{={MERGEFIELD COURSEDATE \@ yyyy}+4800-a}}
{SET c{={MERGEFIELD COURSEDATE \@ M}+12*a-3}}
{SET d{MERGEFIELD COURSEDATE \@ 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}" \@ "d MMMM yyyy"}

which is why you need to copy it

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Ren wrote:
I am merging a date from Access into Word and i want it to say the
date two days after the date in the database. I'm using the following
for the merge field:

{ Mergefield CourseDate \@ "d" } \* ordinal } { Mergefield CourseDate
\@ "MMMM, yyyy" }

but i can't figure out where to add the "+2" bit.



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Ren Ren is offline
external usenet poster
 
Posts: 9
Default Adding 2 days to a mail merge field

Thanks for both of your relpies - sounds like the most simple way is to add a
field into Access

"Graham Mayor" wrote:

Adding days to dates in fields is extremely complicated and not simply a
question of adding '2'. See macropod's document on the subject at
http://www.gmayor.com/downloads.htm#Third_party Copy the relevant field
construction to your document and in it replace DATE with Mergefield
CourseDate and set the delay to 2 which will give you something like:

{QUOTE
{SET Delay 2}
{SET a{=INT((14-{MERGEFIELD COURSEDATE \@ M})/12)}}
{SET b{={MERGEFIELD COURSEDATE \@ yyyy}+4800-a}}
{SET c{={MERGEFIELD COURSEDATE \@ M}+12*a-3}}
{SET d{MERGEFIELD COURSEDATE \@ 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}" \@ "d MMMM yyyy"}

which is why you need to copy it

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


Ren wrote:
I am merging a date from Access into Word and i want it to say the
date two days after the date in the database. I'm using the following
for the merge field:

{ Mergefield CourseDate \@ "d" } \* ordinal } { Mergefield CourseDate
\@ "MMMM, yyyy" }

but i can't figure out where to add the "+2" bit.




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding 30 days to date field in merge Leogal Microsoft Word Help 1 May 4th 07 07:00 PM
Adding days to Merge Field TotallyConfused Mailmerge 7 March 22nd 07 09:03 PM
Adding New Merge Field Noella Mailmerge 2 October 25th 06 02:58 PM
How to get a date merge field to show a date 60 days in the future George Mailmerge 6 March 2nd 06 07:17 AM
Adding a field to an Off 97 mail merge using Office Pro 2003 TomC Mailmerge 1 January 5th 06 08:00 AM


All times are GMT +1. The time now is 03:40 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"