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

Add X months field to a defined date

New Here ,
May 17, 2024 May 17, 2024

I'm trying to create a custom calculation script in adobe acrobat pro to do the following:

 

Commencement date field - enter date

Term field - enter number of months - for example 6 months

End date - calculate by taking the commencement date and adding the number of months specified in the term field.

 

Here's what I currently have - the month changes depending on whats in the term field but for some reason it's added 4 year so to the end date. What do I need to change for this script to work. Many thanks in advance for any ones help 🙏🏼


var getMonth = this.getMonth("TERM"); var strDate = this.getField("COMMENCEMENT DATE").valueAsString; // Test for date format if (/\d{1,2}\/\d{1,2}\/\d{2}/.test(strDate)) { var dt= util.scand("dd/mm/yyyy", strDate); dt.setMonth(dt.getMonth()+getMonth); dt.setDate(dt.getDate()-1); event.value=util.printd("dd/mm/yyyy",dt) } else {event.value=""}

 

 

TOPICS
JavaScript , PDF forms
448
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 ,
May 17, 2024 May 17, 2024

Try this:

change the name of variable getMonth.

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 ,
May 17, 2024 May 17, 2024
LATEST

The first line of your code doesn't make sense. If you're trying to access a field you need to use getField, and naming a variable the same as a method of the Date object is a bad idea, as was mentioned above.

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