Hi,
One way would be to use a library like MomentJS, https://momentjs.com/ . With this library you could write code like;
moment("2016-06-05").diff("2014-01-01", "months") for complete months
or
moment("2016-06-05").diff("2014-01-01", "months", true) for a fractional value
then
moment("2016-06-05").diff("2014-01-01", "years") for the year value
Here is an example, MonthsYearsDiff (https://sites.google.com/site/livecycledesignercookbooks/home/MonthsYearsDiff.pdf?attredirects=0&d=1 ), of using this library in a situation like yours, refer to the code in the calculate event of the
MonthsYearsDiff subform.
There is some other examples of date handling in this blog, Adobe LiveCycle Designer Cookbooks by BR001: Date handling in Livecycle Designer ES forms
Regards
Bruce