Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date .getMonth和.getYear等赢得';无法从Google表单中正确提取日期_Date_Google Apps Script_Google Sheets - Fatal编程技术网

Date .getMonth和.getYear等赢得';无法从Google表单中正确提取日期

Date .getMonth和.getYear等赢得';无法从Google表单中正确提取日期,date,google-apps-script,google-sheets,Date,Google Apps Script,Google Sheets,我将日期存储在谷歌表单的一列中,我想提取部分日期,例如年和月。我试图仿效我找到的例子,但它们不起作用。代码如下: var analysisSS = SpreadsheetApp.getActiveSpreadsheet(); var analysisSheet = analysisSS.getSheetName(); var monthsListRange = analysisSS.getRangeByName(MonthDateRange); var monthsList = monthsLi

我将日期存储在谷歌表单的一列中,我想提取部分日期,例如年和月。我试图仿效我找到的例子,但它们不起作用。代码如下:

var analysisSS = SpreadsheetApp.getActiveSpreadsheet();
var analysisSheet = analysisSS.getSheetName();
var monthsListRange = analysisSS.getRangeByName(MonthDateRange);
var monthsList = monthsListRange.getValues();
var monthPointer = 1;
var monthCode = monthsList[monthPointer].getMonth();
这将生成错误消息:

类型错误:在对象Sun Jan 01 2017 00:00:00 GMT-0800(PST)中找不到函数getMonth。详细信息DISMISS


这是存储在电子表格列第一个单元格中的正确日期。

如果需要答案,请使用适当的标记。以
monthlist[monthPointer][0].getMonth()为例使用双索引,因为getValues返回一个2D数组。