I have an array which has a date in the 3rd column, and I wrote the following script to calculate the Friday on or after that day. The script works (after a little trouble) but unfortunately while it adds the new column, it also overwrites column 3 with the Friday date.
Any advise would be much appreciated.
Logger.log("Started Week Ending");
newData[0].push("Week Ending");
for(i = 1; i < newData.length; i++) {
l = newData[i][2] ;
for(;l.getDay() != 5;) {
l.setDate(l.getDate()+1);
}
newData[i].push(l);
}
Basically I want the variable "lowercase L" to change value but not the source of its value newData[i][2]. Any idea what I am doing wrong?
I first posted this in Google Docs Forum and was advised I might find more help here. Since posting, I tried a variation of this part of the code instead directly filling the array and manipulating the new column value instead of an intermediate variable. The code for this is below:
Logger.log("Started Week Ending");
newData[0].push("Week Ending");
for(i = 1; i < newData.length; i++) {
newData[i].push(newData[i][2]) ;
for(;newData[i][20].getDay() != 5;) {
newData[i][20].setDate(newData[i][20].getDate()+1);
}
}
Thank you for looking! Eric