i\'ve a google spreadsheet that is a 2 columns table that has on column A dates (i\'m sure that are dates, and all the date functions works fine on all the column) and on column
I've created a similar spreadsheet (first column with text, second with dates) and the following script:
function myFunction() {
var sheet = SpreadsheetApp.openById("…");
var ss = sheet.getSheetByName("testing");
var range = ss.getRange(1,1,ss.getLastRow(),ss.getLastColumn());
var data = range.getValues();
var filtered = data.filter(function (row) {
return row[1].getFullYear() === 2016;
});
Logger.log(filtered);
}
And it works as long as the second column is of Date type (Format→Number→Date). I get the error you've described if I change the type to Text. If there are no errors in your code (like .getFullYear instead of .getFullYear() as it's a function, not a property), I think the data (not the variable, but the spreadsheet's data) is not of Date type.