I'm working on a scheduling app using Google Sheets and Apps Scripts. I'm trying to figure out what code to use to increment the date one day at a time starting with a certain date. What I've tried so far is...
var startdate = "1/13/19";
var dt = new Date(startdate);
newSheet.getRange("C1").setValue(dt);
// increment date by 1 day
dt = new Date(dt + 86400);
newSheet.getRange("D1").setValue(dt);
// increment date by 1 day
dt = new Date(dt + 86400);
newSheet.getRange("E1").setValue(dt);
The values I get in C1, D1, E1 are 1/13, 1/13, 1/13. If I use 86400000 milliseconds as an increment value I get 12/31/1969 as a result.
Google's Spreadsheet service does not seem to support much in the way of date functions. There's got to be a way to do this. Thanks for any guidance.
Date
instance methods. You can review these in your preferred javascript language reference. As a start, make sure your input string actually parses to a validDate
. – tehhowch