跳到主要内容

WEEKNUM

返回年份中的周数。

语法

expression.WEEKNUM(arg1, arg2);

expression - 表示 ApiWorksheetFunction 类的变量。

参数

名称必需/可选数据类型默认值描述
arg1必需ApiRange | ApiName | number用于日期和时间计算的日期时间代码。
arg2可选ApiRange | ApiName | number确定返回值类型的数字(1 或 2):星期日 (1) 或星期一 (2)。

返回值

number

示例

获取电子表格中日期在年份中的周数。

// How do I find which week of the year a specific date belongs to in a spreadsheet?

// Calculate the numeric week position for any date in a spreadsheet.

const worksheet = Api.GetActiveSheet();

let func = Api.WorksheetFunction;
let ans = func.WEEKNUM("11/5/2018", 2);

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