Number of days from today's date and specific date

please send me code for calculating number of days from today’s date and specific date

1 Like

Yes this code works. But i want to get the difference from today’s date and i don’t know how to add today’s date in code.

lookup on the internet how to get today’s date in javascript or python

Which side you want to do that?

frappe.ui.form.on(“Installation Note”, “refresh”, function(frm, cdt, cdn){
var d = locals[cdt][cdn];
frappe.model.set_value(cdt, cdn, “days_pending”, frappe.datetime.get_day_diff(get_today() , d.Installation_Date));
refresh_field(“days_pending”);
});

I am using above code but i am not sure whether get_today() works for today’s date?

I tried but doesn’t work. somehow i don’t get difference in days from today’s date.

execute this get_today in browser console

Where exactly in browser console?

In Chrome, Press F12 to start the developer tools. Then click on console.

custom script

I tried below code

frappe.ui.form.on(“Installation Note”, “refresh”, function(frm, cdt, cdn){
var d = locals[cdt][cdn];
var today = new Date(frappe.datetime.nowdate());
var dd = today.getDate();
var mm = today.getMonth()+1;
var yyyy = today.getFullYear();
if(dd<10){ dd=‘0’+dd; } if(mm<10){ mm=‘0’+mm; }
var today1 = dd+‘-’+mm+‘-’+yyyy;
frm.set_value(“form_date”,today1);
frappe.model.set_value(cdt, cdn, “diff_install”, frappe.datetime.get_day_diff( d.form_date, d.Installation_date));
refresh_field(“diff_install”);
});

it works and i can get date format as required but still doesn’t get number of days

1 Like

thanks , its working