Friday, January 6, 2012

calculation of duration between two days in crm4.0 using javascript


// to calculate duration

// get both dates from the form....
var start = crmForm.all.activeon.DataValue;
var end = crmForm.all.expireson.DataValue;

// to cancel the error when undefined
if (start==undefined || start==null || end==undefined || end==null) {
return;
}

// Get 1 day
var day=1000*60*60*24;
// Get time in days...
var time = ((end-start)/day)+1;

// Can't be less than 0.
if (time<0) time=0;
// Set the duration
crmForm.all.new_duration1.DataValue = time;

Reference :-
Gangs036-MS-CRM-Blogspot: calculation of duration between two days in crm4.0...:

No comments:

Post a Comment