I've been trying to set the values in a certain column and for some reason that i cant figure out Its says that my array isn't defined.
function myFunction() {
var Date1 = new Date(); // Today's date
var Sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var arr = Sheet.getRange("AB2:AB6").getValues(); // Recruitment Dates
var Rowlimit = arr.length;
var DaysArr = [new Array()];
for(i = 0 ; i< Rowlimit; i++)
{
var TodayTime = Date1.getTime();
var RecDayTime = (new Date(arr[i][0])).getTime(); //converting from string to Date Type, and converting to the miliseconds number.
var DaysBetween = Math.abs(Math.floor((TodayTime-RecDayTime)/(24*3600*1000))); // Getting the difference in miliseconds and converting the miliseconds to days
Logger.log(DaysBetween);
DaysArr[0].push(DaysBetween);
}
Logger.log(DaysArr);
Logger.log(DaysArr[0]);
Sheet.getRange("AA2:AA6").setValues(Daysarr);
}
below is the execution log, sorry for the wierd language, its just that the drive is set on hebrew
11:03:34 הודעה ההפעלה התחילה
11:03:33 מידע 95.0
11:03:33 מידע 529.0
11:03:33 מידע 382.0
11:03:33 מידע 200.0
11:03:33 מידע 180.0
11:03:33 מידע [[95.0, 529.0, 382.0, 200.0, 180.0]]
11:03:33 מידע [95.0, 529.0, 382.0, 200.0, 180.0]
11:05:25 שגיאה ReferenceError: Daysarr is not defined