How to have a date and subtract 1 year and have a second date for use in display and caculations?
I'm a newbe with JS and find myself fighting the date object
I have declared both currentDate and purchaseDate As var new date() in the globals area
But now in a function I try to assign the Original date as "currentDate and the purchaseDate" as one year later,, The alert shows that I have changed the vaue of currentDate rather than just the value of purchaseDate as I intended..
Not what I want! So I get pass by reference vs by value but don't know how to get this so that I have two separate values for the currentDate and the purchaseDate (one year earlier)
currentDate = data.getValue(0,2);
purchaseDate = valueOf(data.getValue(0,2));
purchaseDate.setFullYear(purchaseDate.getFullYear()-1);
alert(purchaseDate);
so this code fails also; That is,, purchase date is 1 year back but so is current date
currentDate = data.getValue(0,2);
purchaseDate = data.getValue(0,2);
purchaseDate.setFullYear(purchaseDate.getFullYear()-1);
alert(purchaseDate);