Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Adding months to a date

New Here ,
Jul 06, 2017 Jul 06, 2017

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.

TOPICS
Acrobat SDK and JavaScript , Windows
1.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 06, 2017 Jul 06, 2017

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

...
Translate
Community Expert ,
Jul 06, 2017 Jul 06, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 06, 2017 Jul 06, 2017

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2017 Jul 06, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines