Copy link to clipboard
Copied
Hello, I have a calculation that takes place between two fields, between two dates, see example below. I would like the result to be rounded to the nearest whole number. Thank you for your help
(Date 1 - Date 2) / 365 = 5.67 I would like to round lower whole or 5
My code but i have not result
var date1 = this.getField("dateembauche").value;
var date2 = this.getField("dateanciennete").value;
event.value = Math.floor((date1 – date2)/365);
I try this
var date1 = this.getField("dateembauche").value;
var date2 = this.getField("dateanciennete").value;
var result = Math.floor((date1 – date2)/365);
Ce message a été modifié par : SWOON INTERNATIONAL
Copy link to clipboard
Copied
That's not how you calculate the time between two dates, it's a much more complex process.
You should read these tutorials for starters:
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-with-date-and-time-in-acrobat-javascript-part-3
Copy link to clipboard
Copied
Thank you very much I will look and I think the answer.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now