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
Jill
September 23, 2017 at 2:27 am
Where do you put this script?
basiceasy
October 11, 2017 at 12:38 pm
Hi Jill , Please refer below vlog , how to add js in mscrm / dynamics 365
http://www.mscrm.com/2017/10/create-htmljs-file-web-resource-and-add.html
Comments are closed.