I want simply to increment a given date in Cell A1 by 1 day. I need two seperat variables, one for the given date and one variable for the new, incremented date. The problem is, that my code always change both variables and I dont know why.
function testDate() {
var sht_test = SpreadsheetApp.getActive().getSheetByName('Test');
var date_given = sht_test.getRange(1,1).getValue(); // type a Date in cell A1
var date_new;
date_new = date_given;
date_new = new Date(date_new.setDate(date_new.getDate() +1 ));
sht_test.getRange(2,1).setValue(date_new);
sht_test.getRange(2,2).setValue(date_given);
}