ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

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


#1

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


#2
moment(d1).diff(d2, "months");

#3
frm.set_value("resignation_date", frappe.datetime.add_months(frm.doc.posting_date, 1));

#4
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)
	},