Please wait, loading...

 

Get Difference in days between two date fields using javascript ( differences between dates )

March 12, 20152
Hello , below you will find function calculating difference in days between two field using java script .
function diffrenceindays() {
var startdate = GetDateValue(startfield);
var Enddate = GetDateValue(endfield);

var oneday = 1000 * 60 * 60 * 24;
var differenceInDays = ((Enddate - startdate) / oneday);
if (differenceInDays < 0) {
alert(" date cannot be less then start date");

}
alert(" diffrence in days " + differenceInDays);

}

function GetDateValue(field) {


var year = field.getFullYear();
var month = field.getMonth();
var day = field.getDate();
dateOnly = new Date(year, month, day);
return dateOnly;


}

SOURCE : JUST2CODE.IN Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012

2 comments

Comments are closed.

https://i0.wp.com/microsoftdynamics.in/wp-content/uploads/2020/04/Microsoftdynamics365.png?fit=640%2C651
Microsoft Dynamics Community Profile

Learn more