I have an array that contains the months of the year and I want to extract a numerical value for a given month. For example, if the month is March it should return 3 (which I was able to achieve by specifying an individual index within the array).
I want to do the same however I want to setup a for loop that iterates through the columns of each cell and returns a numerical value for all 12 months. Currently, I am getting an error that states, “The parameters (number[],String,String) don’t match the method signature for Utilities.formatDate.” How can I resolve this? A portion of my code is below.
function allData_Price_2020 (sheet1, sheet2) {
var data1 = sheet1.getRange("B:D").getValues(); // Get all PNs, CCs, LCs
var data2 = sheet2.getRange("A:A").getValues(); // Get concatenated PNs, CCs, LCs
var data3 = sheet2.getDataRange().getValues(); // Get all data from tab
var data4 = sheet1.getRange(4, 93, 1, 12).getValues(); // Get months from Price Table in tab
for (var i = 4; i < data1.length; i++) { // Start iteration on row 5
for (var j = 1; j < data4[0].length; j++) {
var data4 = sheet1.getRange(4, 93, 1, 12).getValues(); // Get months from Price Table in tab
var month = Utilities.formatDate(data4,Session.getScriptTimeZone(), "MM"); // Extracts the month from date timestamp
// Rest of the code is irrelevant
}
}
}