Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Kathy Webster Kathy Webster is offline
external usenet poster
 
Posts: 23
Default If statement with a date

In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years and
1 day AFTER the DateOfLoss. :-)
Any takers?


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
macropod macropod is offline
external usenet poster
 
Posts: 1,002
Default If statement with a date

Hi Kathy,

To do this you could code your field as:
{QUOTE
{SET MDate {MERGEFIELD DateOfLoss}}
{SET a{=INT((14-{MDate \@ M})/12)}}
{SET b{={MDate \@ yyyy}+4802-a}}
{SET c{={MDate \@ M}+12*a-3}}
{SET d{MDate \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32044}}
{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"}

Rather than creating all this yourself, you can download my Date Calc 'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
and modify the example under 'Calculate a day, date, month and year, using n days delay' to suit.

The key changes a
.. change {SET Delay 14}to {SET MDate {MERGEFIELD DateOfLoss}}
.. change all 'DATE' strings to 'MDate'
.. change '4800' on the 4th line to '4802'
.. change '32045+Delay' on the 7th line to '32044'

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Kathy Webster" wrote in message ink.net...
In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years and
1 day AFTER the DateOfLoss. :-)
Any takers?


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default If statement with a date

macropod's solution is just fine, but if your data source is something like
Access you can also consider using a query to give the right date, which may
help keep the complexity of your Word documents down.

Peter Jamieson
"Kathy Webster" wrote in message
ink.net...
In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years
and 1 day AFTER the DateOfLoss. :-)
Any takers?



  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Kathy Webster Kathy Webster is offline
external usenet poster
 
Posts: 23
Default If statement with a date

Thank you. There are so many different requirements for different date
scenarios. That's why I need to address the issue in Word rather than in my
access data source. I would love to have Access handle it, since I know
what I'm doing there! :-) Unfortunately, I need to build my Word chops.

"Peter Jamieson" wrote in message
...
macropod's solution is just fine, but if your data source is something
like Access you can also consider using a query to give the right date,
which may help keep the complexity of your Word documents down.

Peter Jamieson
"Kathy Webster" wrote in message
ink.net...
In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years
and 1 day AFTER the DateOfLoss. :-)
Any takers?





  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Kathy Webster Kathy Webster is offline
external usenet poster
 
Posts: 23
Default If statement with a date

Yee-hikes! Thank you for doing the heavy lifting!
xxoo

"macropod" wrote in message
...
Hi Kathy,

To do this you could code your field as:
{QUOTE
{SET MDate {MERGEFIELD DateOfLoss}}
{SET a{=INT((14-{MDate \@ M})/12)}}
{SET b{={MDate \@ yyyy}+4802-a}}
{SET c{={MDate \@ M}+12*a-3}}
{SET d{MDate \@ d}}
{SET jd{=d+INT((153*c+2)/5)+365*b+INT(b/4)-INT(b/100)+INT(b/400)-32044}}
{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"}

Rather than creating all this yourself, you can download my Date Calc
'tutorial', at:
http://www.wopr.com/cgi-bin/w3t/show...?Number=249902
and modify the example under 'Calculate a day, date, month and year, using
n days delay' to suit.

The key changes a
. change {SET Delay 14}to {SET MDate {MERGEFIELD DateOfLoss}}
. change all 'DATE' strings to 'MDate'
. change '4800' on the 4th line to '4802'
. change '32045+Delay' on the 7th line to '32044'

Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------

"Kathy Webster" wrote in message
ink.net...
In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years
and 1 day AFTER the DateOfLoss. :-)
Any takers?





  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default If statement with a date

I would love to have Access handle it, since I know what I'm doing there!
:-)


:-) Well, you're probably better off following your existing approach, but
if you really prefer Access/Jet/VBA-style date calculations, see

http://tips.pjmsn.me.uk/t0004.htm

Peter Jamieson

"Kathy Webster" wrote in message
ink.net...
Thank you. There are so many different requirements for different date
scenarios. That's why I need to address the issue in Word rather than in
my access data source. I would love to have Access handle it, since I
know what I'm doing there! :-) Unfortunately, I need to build my Word
chops.

"Peter Jamieson" wrote in message
...
macropod's solution is just fine, but if your data source is something
like Access you can also consider using a query to give the right date,
which may help keep the complexity of your Word documents down.

Peter Jamieson
"Kathy Webster" wrote in message
ink.net...
In a mailmerge doc, I have {MERGEFIELD DateOfLoss}. I do not want the
merged doc to print the DateOfLoss: I want it to print the date 2 years
and 1 day AFTER the DateOfLoss. :-)
Any takers?







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
which statement right , question is Choose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 16th 06 11:15 AM
which statement right , question isChoose the correct statement? how many template?when we click new doc Microsoft Word Help 1 October 15th 06 11:20 PM
using iif statement Boots Mailmerge 3 June 19th 06 03:23 PM
if statement Boots Microsoft Word Help 2 June 2nd 06 02:11 PM
IF Statement Shoelaces Mailmerge 5 November 23rd 05 06:54 AM


All times are GMT +1. The time now is 08:48 PM.

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"