跳到主要内容

EOMONTH

返回指定月数之前或之后月份最后一天的序列号。

语法

expression.EOMONTH(arg1, arg2);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | number表示开始日期的序列日期数字。
arg2必需ApiRange | ApiName | number开始日期之前或之后的月数。

返回值

number

示例

查找电子表格中指定月数之后的月份的最后一天。

// How do I get the end date of a month by counting months forward or backward in a spreadsheet?

// Calculate the final date of a month relative to a starting date in a spreadsheet.

const worksheet = Api.GetActiveSheet();

let func = Api.WorksheetFunction;
let ans = func.EOMONTH("3/16/2018", 10);

worksheet.GetRange("C1").SetValue(ans);