View Single Post
Old 02-13-2013, 07:36 AM
lhuffst lhuffst is offline Windows 7 64bit Office 2010 32bit
Join Date: Feb 2013
Posts: 1
lhuffst is on a distinguished road
Default need help understanding mailmerge code

I am new to mailmerge and do not understand all of the following code.
It is supposed to return the first day of the next month of the formfield (orgdate). If the date is null then use current date.
What I get is the first date of the last month

When I went through the code, I realized that I didn't really understand all of the lines of code and am hoping someone can explain it to me, particularly the mod statements.
Effective Date: {QUOTE{QUOTE
{SET ORGDATE {IF{ MERGEFIELD "InvoiceDate"}="" {MERGEFIELD "Date_Stamp" \@ 
M/d/yyyy} {MERGEFIELD "InvoiceDate" \@ M/d/yyyy}} }
{SET Delay 1}
{SET mm {=MOD(ABS({ORGDATE\@M}+Delay+11),12)+1}}
{SET yy{=INT({ORGDATE}\@ YYYY}+(dELAY+{ORGDATE \@ M}-1)/12)}}
{SET dd{=IF(({ORGDATE}\@ D}>28)*(MM=2)=1,28+((mod(yy,4)=0)+(MOD(yy,400)=0)-
(MOD(yy,100)=0)),IF((mm=4)+(mm=6)+(mm=9)+(mm=11)+{ORGDATE\@ d}>30)>1,30,{
ORGDATE \@ d}))}}
"{delay}-{mm}-{yy}" \@ "M/d/yyyy"}}
Reply With Quote