谷歌表自定义函数内置函数 [英] google sheets custom function built-in function

查看:379
本文介绍了谷歌表自定义函数内置函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Google表格中有以下自定义函数,我尝试在自定义函数中调用内置函数 TEXT,但未成功。 Google表格会提示未知功能 TEXT。有解决方案吗?

I have following custom function in google sheets, I tried to call a built-in function "TEXT" in my custom function but it is not successful. The Google sheets will prompt "unknown" function "TEXT". Is there solution?

Tks
Leon

Tks Leon

function NextMonth(StockTradeDate) {
  var DeltaDate;
  if (**TEXT**(StockTradeDate,"mmm") = "JAN" ) {
  DeltaDate = 30;
      }
  return DATEVALUE(StockTradeDate) + 31;    
}


推荐答案

尝试使用javascript日期方法(如下所示)来确定所需的日期和条件。无法在应用程序脚本函数中找到支持Sheets内置函数调用的文档。支持Javascript。

Try using javascript date methods (as below) to drive the date and conditionals you need. Could not locate documentation that supports the Sheets built-in function calls from within an apps script function. Javascript is supported.

function NEXTMONTH(StockTradeDate) {

  var DeltaDate

    if (StockTradeDate.getMonth() === 0 ) { //Jan:0  Feb:1 ... Dec:11 these will need more conditionals. 
    DeltaDate = 30;
    }

  var date2 = new Date(StockTradeDate.valueOf()+ DeltaDate*24*60*60*1000)
                                   // valueOf() is millisec time since 1/1/1970
  return date2
}

如果您需要有关日期的方法和实现,对w3schools具有有效的参考。

If you need more info regarding the date methods and implementation, w3schools has an efficient reference.

这篇关于谷歌表自定义函数内置函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆