I am trying to run a 'for' loop that looks like this:
function runMultipleDates() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
//9/26/2018 is 1569477600000 and 2/28/2019 is 1551337200000; 9/21/2018 is 1537509600000
for (var date1 = 1537596000000 /*9/21/2018*/; date1 < 1569477600000 /*9/26/2018*/; date1 +=86400000) {
//runEverything();
var date2 = new Date();
date2 = date2.setTime(date1);
ss.getSheetByName('Time Range').getRange("A3").setValue(date2);
};
};
My goal is to run a function called "runEverything()" that reference a date located in cell A3 of a sheet called 'Time Range'. As long as the date in cell A3 is less that 9/26/2018, the for loop should run my function 'runEverything' and then set a new date in A3. When I do my test loop, the setValue(date2) returns a numeric value rather than a date in that cell (A3). Can someone point out how I can return the date format rather than the numeric value of date? if there is a more elegant way to achieve this, I am all ears!
Thank you for your insight!