Asif Faleel
asked on
Calculate the Difference between 2 Date Fields as a Report In Dynamics CRM 2011
Hi,
I have 2 fields in My Opportunity form and i need to calculate the difference between the 2 dates for each Opportunity and produce a report or View.
Kindly help as to how i can achieve that.
Thanks,
Asif
I have 2 fields in My Opportunity form and i need to calculate the difference between the 2 dates for each Opportunity and produce a report or View.
Kindly help as to how i can achieve that.
Thanks,
Asif
ASKER
Java Script.
Opportunity form.
Opportunity form.
You can use this custom function:
function diffDays( date1, date2 ) {
//Get 1 day in milliseconds
var one_day=1000*60*60*24;
// Convert both dates to milliseconds
var date1_ms = date1.getTime();
var date2_ms = date2.getTime();
// Calculate the difference in milliseconds
var difference_ms = date2_ms - date1_ms;
// Convert back to days and return
return Math.round(difference_ms/o ne_day);
}
this function should be included, then use:
var diff_in_days = diffDays(d1,d2);
function diffDays( date1, date2 ) {
//Get 1 day in milliseconds
var one_day=1000*60*60*24;
// Convert both dates to milliseconds
var date1_ms = date1.getTime();
var date2_ms = date2.getTime();
// Calculate the difference in milliseconds
var difference_ms = date2_ms - date1_ms;
// Convert back to days and return
return Math.round(difference_ms/o
}
this function should be included, then use:
var diff_in_days = diffDays(d1,d2);
ASKER
Give me few days on this i will try it and let you know.
ASKER
How do i exclude weekends while calculating the time difference.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Done
So kindly state what scripting language you are using, what kind of variables your two dates are, and in what form you want to see the difference between them.