Copy link to clipboard
Copied
How do create a form field that will add 6 months to a date from another field? The idea is to output an expiration date 6 months after a training date that is entered by the user.
1 Correct answer
OK, in that case you will need to decide what method to use and then write a script that takes the string value from the first field, converts it to a Date object (using the scand method of the util object), adds the desired amount of time to it and then prints out the result (using the printd method) to the target field. This tool by Joel Geraci could be a great help in doing that: http://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/
If you're interested, I've developed a to
...Copy link to clipboard
Copied
Sounds like a simple task, but it's not. What does "6 months" mean, exactly? 180 days? 6 calendar months? What if the original date is March 31st, for example? There is no September 31st... Should it be September 30th, then? Or October 1st? etc.
Copy link to clipboard
Copied
I have been using a formula in Excel to do this and it rounds down to 9/30 in that situation. Honestly, any of those options would work for me as anyone questioning the 6 month period will have the same conundrum.
Copy link to clipboard
Copied
OK, in that case you will need to decide what method to use and then write a script that takes the string value from the first field, converts it to a Date object (using the scand method of the util object), adds the desired amount of time to it and then prints out the result (using the printd method) to the target field. This tool by Joel Geraci could be a great help in doing that: http://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/
If you're interested, I've developed a tool that allows you to set up exactly this kind of calculation easily and without having to write any code. You can find it here: Custom-made Adobe Scripts: Acrobat -- Apply Automatic Date Calculation

