How can I subtract days from a date field?
Example:
Date Value is 03/10/2014 (mm/dd/yy),
I want to be able to subtract 6 weedays from it to get 03/03/2014
Can someone please help me get this.
Fiddle: to add 6 weekdays and disable all previous date values... From this fiddle whatever date is selected 6 weekdays must be subtracted from it.
i.e $("#txtFromDate").val() - 6 weekdays
http://jsfiddle.net/7DHVr/8/
Thanks in advance
var count = 10;
//Add the 2 days of weekend in numer of days .
var d = new Date();
count = count + (parseInt(count/5))*2;
d.setDate(d.getDate() -count);
//suppose its ending on weekend day then increment them manually.
if(d.getDay() == 6 ) d.setDate(d.getDate() -1);
if(d.getDay() == 0){ d.setDate(d.getDate() - 2);};
alert(d);
it will substract all weekend day from whatever you want to substract day dynamically