Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
which statement right , question is Choose the correct statement? | Microsoft Word Help | |||
which statement right , question isChoose the correct statement? | Microsoft Word Help | |||
using iif statement | Mailmerge | |||
if statement | Microsoft Word Help | |||
IF Statement | Mailmerge |