Reputation: 55
I have a table on my opportunities won tab that has a date, the logger finds the dates just fine. But I want to use the month to categorize each input on the opportunities tab, regardless of day or year, into the summary tab jan-dec. I found .getMonth()
but it says the error that it cannot find function .getMonth()
in object. I am trying to get the object to be the current row (var i
)
var ss = SpreadsheetApp.getActiveSpreadsheet();
var summary = ss.getSheetByName("Summary")
var oppwon = ss.getSheetByName("Opportunities Won");
var j = oppwon.getLastRow();
for(var i =8;i<=j;i++) {
var dates = oppwon.getRange(i,22).getValue();
var tiers = oppwon.getRange(i,14).getValue();
var month = dates.getMonth();
Logger.log(dates.getMonth());
Upvotes: 2
Views: 53
Reputation: 2926
If dates is just an input of a date mm/dd/yy
, cast to new Date()
before usage:
new Date(dates).getMonth();
Upvotes: 1