Date.yearDiff()
The Date.yearDiff() API returns the difference between two date, time, or timestamp fields in years.
Parameters
Date/time 1
Date/time 2
Return Value
Number of years between the two dates/times
Example
pjs.define("date", { type: 'date', initValue: '2017-01-01'});
pjs.define("date1", { type: 'date', initValue: '2021-01-01'});
pjs.define("diff", { type: 'integer'} );
diff = Date.yearDiff(date1, date);
Â
return diff;
// 4
RPG Equivalent
%DIFF()