Try ERPNext Buy Support Partners Foundation

How to get Difference in months between two dates using custom script

How to get Difference in months between two dates using custom script

moment(d1).diff(d2, "months");
frm.set_value("resignation_date", frappe.datetime.add_months(frm.doc.posting_date, 1));
calculate_months:function(frm){
		var start_date= new Date(frm.doc.start_date)
		var end_date=new Date(frm.doc.end_date)
		numberOfMonths = (end_date.getFullYear() - start_date.getFullYear()) * 12 + (end_date.getMonth() - start_date.getMonth()) + 1;	
		frm.set_value("total_months",numberOfMonths)
	},

error…
Uncaught (in promise) ReferenceError: numberOfMonths is not defined