I am using JS to calculate my date diffrence but i did not get the rounded value please guide me. Formula used to find the Approximate amount
value1 = todate - fromdate;
value2 = value1 / 30;
value3 = value2 * 5000;
for this i am using the following code
var preioddiff = parseInt(todate ) - parseInt(fromdate);
var dividen = preioddiff / 30;
var totappamt = dividen * parseInt(5000);
but it does not give the correct answer
for example From Date is 04012011 and to date is 04022011 if i subtract the value using the parseInt(todate ) - parseInt(fromdate); it return the value 13303380 instead of 0001000
alert(parseInt(todate))? Also, aren't you expecting preioddiff to be 10000, not 1000?