I am getting an error message for a program that normally works, code below:
var sheet = SpreadsheetApp.openByUrl('url.com');
var ss = SpreadsheetApp.setActiveSheet(sheet.getSheetByName('Sheet1'));
var date = new Date();
Logger.log(date); //Sat Aug 22 17:28:54 GMT+01:00 2020
var day = date.getDate();
Logger.log(day); //22
for (var i = 2; i < 1400; i++) {
var gamedandt = ss.getRange(i, 1).getValue();
Logger.log(gamedandt); //Sat Aug 22 14:00:00 GMT+01:00 2020
/*Line 47*/ var gameday = gamedandt.substring(9, 2);
}
}
The error message I receive says:
TypeError: gamedandt.substring is not a function (line 47, file "myFile")
I believe the problem to be the data I want substringed - it is a date. The script worked fine in the past but the data would simply have the date and time (eg. '22 14:00') rather than the now full date which includes month, year, weekday, etc.