Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.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
Google apps script Google应用程序脚本函数返回空白_Google Apps Script - Fatal编程技术网

Google apps script Google应用程序脚本函数返回空白

Google apps script Google应用程序脚本函数返回空白,google-apps-script,Google Apps Script,我在Google应用程序脚本中定义了以下函数: function getFinYear(date){ var year = parseInt(date.getYear()); var month = parseInt(date.getMonth()); // month is zero based converting it to civilzation today mode month = month + 1; var fin = "" if(month > 7

我在Google应用程序脚本中定义了以下函数:

function getFinYear(date){

  var year = parseInt(date.getYear());
  var month = parseInt(date.getMonth());
  // month is zero based converting it to civilzation today mode
  month = month + 1;
  var fin = ""
  if(month > 7){
    if(year == 2011){
      fin = "Fin 2012";
    }
    else if(year == 2012){
      fin = "Fin 2013";
    }
    else if(year == 2013){
      fin = "Fin 2014";
    }
  }
  return fin;  
}
当我从谷歌电子表格中调用这个函数时,我什么也得不到。我在单元格中有一个值作为日期类型。单元格
B2
中的实际值为
12/03/2012
。我称之为
=getFinYear(B2)

我似乎不明白为什么什么都没有出现


我检查了值是否缓存等。请帮助

单元格B2的类型是否设置为日期?如果将其格式化为文本,则可以修改函数以包括:

date = new Date(date);

更新:您的电子表格似乎希望日期为dd/mm/yyyy格式。

函数运行,但我在单元格上看不到任何内容。是的,类型是date。我刚刚试过,正在表格中得到正确的结果。你能分享你的谷歌表吗?是的,我能。