/
Add days to a mergefield

Add days to a mergefield

Do you need to add a number of days to a merge field?

An example might be that you want a due date for a payment or invoice to be paid.

 

There is a simple formula that you can add to your document template that will do this for you.

 

Download the template here

 

First, you need to select a Date value that this merge field will apply to

You can use

  • Date the order was created - DateDocumented

  • Accept date - AcceptedDate

  • Dispatch / Follow-up date - FollowUpDate

  • Invoiced date - InvoicedDate

If you need to replace the value, do that in the Word document

For example, I have FollowUpDate in the example below, but you might want InvoicedDate, right Click on the FollowUpDate and type (or paste) InvoicedDate

This is case-sensitive and will need to have the capital letters as shown,

Next, set the number of days that you want to add. To do this, change the delay number.

 

{MERGEFIELD FollowUpDate \* MERGEFORMAT}

{QUOTE

{SET Delay 1}

{SET a{=INT((14-{MERGEFIELD FollowUpDate \@ M})/12)}}

{SET b{={MERGEFIELD FollowUpDate \@yyyy}+4800-a}}

{SET c{={MERGEFIELD FollowUpDate @ M}+12*a-3}}

{SET d{MERGEFIELD FollowUpDate \@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(1/10)}}

{SET yy{=100*e+g-4800+INT(i/10)}}

"{dd}-{mm}-{yy}" \@"d/MM/yyyy"}

Related content