Need to Calculate difference between 2 dates in YEAR , MONTH & DAYS
I need the difference between 2 dates in three different field:
In first field : it should in Years
2nd Field : it should be Month,
3rd Field : it should be Days
For ex- First Date: 14/05/1998 second date: 18/04/2019
difference should show 1st Field: 20 years
2nd Field : 11 months
3rd Field : 04 days
I searched regarding this on this community and found few scripts, accordingly i converted the full difference in milliseconds.. and converted them to days, months, year.. everything works fine
but days are not calculated correctly due to 30,31, 28,29 days and in month due leap year.
Below are the scripts used after the difference is converted to milliseconds (TotalTime_MS)
for day field:
event.value = Math.floor((this.getField("TotalTime_MS").value)/(1000*60*60*24)%365.25);
For Month Field:
event.value = Math.floor( ((this.getField("TotalTime_MS").value)/(1000*60*60*24*30))%12 );
For Year Field:
event.value = Math.floor((this.getField("TotalTime_MS").value)/(1000*60*60*24*365.25));
Thanks in advance
