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);