Calculate Number of Days between two Dates in MS CRM
Some time we need to calculate number of days between two dates in crm, we can easily do this using below JS script var d1=crmForm.all.FirstDate.DataValue; var d2=crmForm.all.SecondDate.DataValue; var DayValue=1000*60*60*24; alert(Math.ceil((d2.getTime()-d1.getTime())/DayValue)); Update for Dynamics 365 var d1=Xrm.Page.getAttribute(“FirstDate”).getValue(); var d2=Xrm.Page.getAttribute(“SecondDate”).getValue(); var DayValue=1000*60*60*24; alert(Math.ceil((d2.getTime()-d1.getTime())/DayValue));