calculating between two dates

New Here ,
Nov 25, 2019

Copy link to clipboard

Copied

Help please

I'm working (under Acrobat X)

I created a date feild  called : "DG"

and another feild called "TP"

I have to calculate between different dates.

I would like "TP = DG + 39 weeks" in the form dd/mm/yyyy but i need so that the day stays the same.

exemple if DG : is 01/08/2019 the TP must be 01/05/2020 (in another way the month + 9 (month = 28 jours).

 

var sDate = this.getField("StartDate").value; // get date string var nWeeks = 39; // get or set the weeks to add var oDate = util.scand("dd/mm/yyyy", sDate); // convert to object oDate.setDate(oDate.getDate() + (7 * nWeeks) ); // add 7 days * number of weeks to date event.value = util.printd("dd/mm/yyyy", oDate); // format result

Help me please

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

92

Likes

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

calculating between two dates

New Here ,
Nov 25, 2019

Copy link to clipboard

Copied

Help please

I'm working (under Acrobat X)

I created a date feild  called : "DG"

and another feild called "TP"

I have to calculate between different dates.

I would like "TP = DG + 39 weeks" in the form dd/mm/yyyy but i need so that the day stays the same.

exemple if DG : is 01/08/2019 the TP must be 01/05/2020 (in another way the month + 9 (month = 28 jours).

 

var sDate = this.getField("StartDate").value; // get date string var nWeeks = 39; // get or set the weeks to add var oDate = util.scand("dd/mm/yyyy", sDate); // convert to object oDate.setDate(oDate.getDate() + (7 * nWeeks) ); // add 7 days * number of weeks to date event.value = util.printd("dd/mm/yyyy", oDate); // format result

Help me please

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to, PDF forms

Views

93

Likes

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
Nov 25, 2019 0
Adobe Community Professional ,
Nov 25, 2019

Copy link to clipboard

Copied

Hi,

 

There is a paid for script by Try67 found here: https://try67.blogspot.com/2012/01/acrobat-apply-automatic-date.html

 

Or,

 

use Thom Parker's tutorial on how to calculate difference in days between two dates also posted by Try67 in the following thread:

 

https://community.adobe.com/t5/acrobat/calculate-difference-between-two-time-fields/td-p/10042084

Likes

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
Reply
Loading...
Nov 25, 2019 0
Adobe Community Professional ,
Nov 25, 2019

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Nov 25, 2019 0
Adobe Community Professional ,
Nov 25, 2019

Copy link to clipboard

Copied

Or you can use Joel Garcia's free date library here:

https://practicalpdf.com/the-practicalpdf-date-library-for-adobe-acrobat/

 

Likes

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
Reply
Loading...
Nov 25, 2019 1