0
function Get_month_column_summary()
{
  var month = sheetToPlan.getRange(2, 3).getValue();
  Logger.log(month);
  var lastCol = summarySheet.getLastColumn();
  var lookupRangeValues = summarySheet.getRange(2,1,1,lastCol).getValues();
  var concat = [].concat.apply([],lookupRangeValues);
  Logger.log(concat);
  var index = concat.indexOf(month) + 1;
  Logger.log(index);

  return index;
}

So basically, I'm trying to find the index of a specific date that I got from sheet 1 and trying to find that same date in sheet 2. But when the index gives me -1 (i added 1 so it shows 0 instead of -1 in logs) for some reason, even though i see that it is in the array, the date that im searching for. It is in the exact same format and wording, 100% the same. but the indexOf still gives me -1. Any idea what is going on here?

[20-05-27 18:21:43:667 HKT] **Fri May 01 00:00:00 GMT+08:00 2020**

[20-05-27 18:21:44:002 HKT] [Sun Jan 01 00:00:00 GMT+08:00 2017,
 Wed Feb 01 00:00:00 GMT+08:00 2017,
 Wed Mar 01 00:00:00 GMT+08:00 2017,
 Sat Apr 01 00:00:00 GMT+08:00 2017,
 Mon May 01 00:00:00 GMT+08:00 2017,
 Thu Jun 01 00:00:00 GMT+08:00 2017,
 Sat Jul 01 00:00:00 GMT+08:00 2017,
 Tue Aug 01 00:00:00 GMT+08:00 2017,
 Fri Sep 01 00:00:00 GMT+08:00 2017,
 Sun Oct 01 00:00:00 GMT+08:00 2017,
 Wed Nov 01 00:00:00 GMT+08:00 2017,
 Fri Dec 01 00:00:00 GMT+08:00 2017,
 Mon Jan 01 00:00:00 GMT+08:00 2018,
 Thu Feb 01 00:00:00 GMT+08:00 2018,
 Thu Mar 01 00:00:00 GMT+08:00 2018,
 Sun Apr 01 00:00:00 GMT+08:00 2018,
 Tue May 01 00:00:00 GMT+08:00 2018,
 Fri Jun 01 00:00:00 GMT+08:00 2018,
 Sun Jul 01 00:00:00 GMT+08:00 2018,
 Wed Aug 01 00:00:00 GMT+08:00 2018,
 Sat Sep 01 00:00:00 GMT+08:00 2018,
 Mon Oct 01 00:00:00 GMT+08:00 2018,
 Thu Nov 01 00:00:00 GMT+08:00 2018,
 Sat Dec 01 00:00:00 GMT+08:00 2018,
 Tue Jan 01 00:00:00 GMT+08:00 2019,
 Fri Feb 01 00:00:00 GMT+08:00 2019,
 Fri Mar 01 00:00:00 GMT+08:00 2019,
 Mon Apr 01 00:00:00 GMT+08:00 2019,
 Wed May 01 00:00:00 GMT+08:00 2019,
 Sat Jun 01 00:00:00 GMT+08:00 2019,
 Mon Jul 01 00:00:00 GMT+08:00 2019,
 Thu Aug 01 00:00:00 GMT+08:00 2019,
 Sun Sep 01 00:00:00 GMT+08:00 2019,
 Tue Oct 01 00:00:00 GMT+08:00 2019,
 Fri Nov 01 00:00:00 GMT+08:00 2019,
 Sun Dec 01 00:00:00 GMT+08:00 2019,
 Wed Jan 01 00:00:00 GMT+08:00 2020,
 Sat Feb 01 00:00:00 GMT+08:00 2020,
 Sun Mar 01 00:00:00 GMT+08:00 2020,
 Wed Apr 01 00:00:00 GMT+08:00 2020,
 **Fri May 01 00:00:00 GMT+08:00 2020**,
 Mon Jun 01 00:00:00 GMT+08:00 2020,
 Wed Jul 01 00:00:00 GMT+08:00 2020,
 Sat Aug 01 00:00:00 GMT+08:00 2020,
 Tue Sep 01 00:00:00 GMT+08:00 2020,
 Thu Oct 01 00:00:00 GMT+08:00 2020,
 Sun Nov 01 00:00:00 GMT+08:00 2020,
 Tue Dec 01 00:00:00 GMT+08:00 2020,
 Fri Jan 01 00:00:00 GMT+08:00 2021,
 Mon Feb 01 00:00:00 GMT+08:00 2021,
 Mon Mar 01 00:00:00 GMT+08:00 2021,
 Thu Apr 01 00:00:00 GMT+08:00 2021,
 Sat May 01 00:00:00 GMT+08:00 2021,
 Tue Jun 01 00:00:00 GMT+08:00 2021,
 Thu Jul 01 00:00:00 GMT+08:00 2021,
 Sun Aug 01 00:00:00 GMT+08:00 2021,
 Wed Sep 01 00:00:00 GMT+08:00 2021,
 Fri Oct 01 00:00:00 GMT+08:00 2021,
 Mon Nov 01 00:00:00 GMT+08:00 2021,
 Wed Dec 01 00:00:00 GMT+08:00 2021,
 Sat Jan 01 00:00:00 GMT+08:00 2022,
 Tue Feb 01 00:00:00 GMT+08:00 2022]

[20-05-27 18:21:44:010 HKT] 0.0
Rafa Guillermo
  • 14,474
  • 3
  • 18
  • 54

1 Answers1

0

This solution may work :

var index = concat.indexOf(month.toString()) + 1;

I you cant to convert all concat data with

var concatstr = []
concat.forEach(e => concatstr.push(e.toString()))
Julien Maret
  • 579
  • 1
  • 4
  • 22