Pages

Sunday 1 July 2012

Find Time Difference of two DateTime filed in CRM2011 Javascript


function onchange_endate()
{
var startday = Xrm.Page.getAttribute("linu_plannedstartdate").getValue();
 var endday = Xrm.Page.getAttribute("linu_plannedenddate").getValue();


if( startday !=null  && endday !=null)
{

var time2= endday.getTime();
var time1=startday.getTime();
 var time3= time2-time1;

var hoursDifference = (time3/1000/60/60);
var  temptime  =Math.round(hoursDifference );
if(temptime >hoursDifference )
{
hoursDifference =hoursDifference -0.20;

}

//here  linu_plannedestimatedtime is floating point number to save result timediffernce.
    Xrm.Page.getAttribute("linu_plannedestimatedtime").setValue(hoursDifference);
}
}

No comments:

Post a Comment