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

Custom Calculation Scripts to PDF calculate Start date from total days and result in end date

New Here ,
Apr 28, 2024 Apr 28, 2024

Copy link to clipboard

Copied

I've looked all over the community forums and tried a few things that people suggested 

I am having trouble finding the right script to calculate the start date and count the total days the result shows in the end date. 
Vacation PDF Formate

For Example

Vacation Start date = 01-04-2024 ="AnVac1"

Vacation Total Days = 30 days = "Total Days"

Vacation End Date = 30-04-2024="AnVac2"

 

I need result in Vacation End Date with script to calulate  

I never have to work with scripts - just need some help this one time. 

TOPICS
Create PDFs , General troubleshooting , How to , JavaScript , PDF , PDF forms

Views

171

Translate

Translate

Report

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 , Apr 29, 2024 Apr 29, 2024

Try this as 'Custom calculation script' of "AnVac2" field:

var f1 = this.getField("AnVac1").valueAsString;
var f2 = this.getField("Total Days").valueAsString;

if (f1 && f2) {
 var date = util.scand("dd-mm-yyyy", f1);
 date.setDate(date.getDate() + (Number(f2) - 1));
 event.value = util.printd("dd-mm-yyyy", date);} 
else {
 event.value = "";}

Votes

Translate

Translate
Community Expert ,
Apr 28, 2024 Apr 28, 2024

Copy link to clipboard

Copied

Are you looking for the total days, or the total working days?


I'm sure that it is possible to do that in Acrobat, but I'm not persuaded that Acrobat is the best application for this.

ABAMBO | Hard- and Software Engineer | Photographer

Votes

Translate

Translate

Report

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 ,
Apr 28, 2024 Apr 28, 2024

Copy link to clipboard

Copied

Yes result date is calculated after the total days

 

Hope someone help to solve this

 

Votes

Translate

Translate

Report

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 ,
Apr 28, 2024 Apr 28, 2024

Copy link to clipboard

Copied

This type of question has been asked (and answered) on these forums many times in the past. Try searching around and you're bound to find some answers, including the code needed to do it.

Alternatively, read these tutorials about working with Time and Date objects in Acrobat JS:

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript

https://acrobatusers.com/tutorials/working-with-date-and-time-in-acrobat-javascript-part-2

https://acrobatusers.com/tutorials/working-date-and-time-acrobat-javascript-part-3-3

 

Or, if you just want a simple solution to your problem, you can use this (paid-for) tool I've developed that allows you to set it up very easily and quickly, without having to write any code:

https://www.try67.com/tool/acrobat-apply-automatic-date-calculation

 

Votes

Translate

Translate

Report

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 ,
Apr 28, 2024 Apr 28, 2024

Copy link to clipboard

Copied

TRY67 I saw many community this same message/thread.

Votes

Translate

Translate

Report

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

Try this as 'Custom calculation script' of "AnVac2" field:

var f1 = this.getField("AnVac1").valueAsString;
var f2 = this.getField("Total Days").valueAsString;

if (f1 && f2) {
 var date = util.scand("dd-mm-yyyy", f1);
 date.setDate(date.getDate() + (Number(f2) - 1));
 event.value = util.printd("dd-mm-yyyy", date);} 
else {
 event.value = "";}

Votes

Translate

Translate

Report

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 ,
Apr 29, 2024 Apr 29, 2024

Copy link to clipboard

Copied

LATEST

Thanks a lot, Nessa Noorani for such accurate and remarkable support for resolving new people's queries.

 

Votes

Translate

Translate

Report

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