模块
目录
索引 🔎︎

## WEEKNUM

WEEKNUM calculates the week number of the year for the internal date value as defined in ODF OpenFormula and compatible with other spreadsheet applications.

Supported are two week numbering systems:

System | Description
System 1 | The week containing January 1 is the first week of the year, and is numbered week 1.
System 2 | The week containing the first Thursday of the year is the first week of the year, and is numbered week 1. That means that week number 1 of any year is the week that contains January 4th. ISO 8601 defines this system and that the week starts on Monday.

### 语法

WEEKNUM(Number; Mode)

「value」是日期的内部序列数。

Mode sets the start of the week and the week numbering system. This parameter is optional, if omitted the default value is 1.

System | Mode | Day of the week
System 1 | 1 | Sunday
2 | Monday
11 | Monday
12 | Tuesday
13 | Wednesday
14 | Thursday
15 | Friday
16 | Saturday
17 | Sunday
System 2 | 21 | Monday (ISO 8601)
150 | (ISO 8601, for interoperability with Gnumeric)

将日期作为公式一部分输入时，日期分隔符 (斜杠与短横线) 会被理解为算术运算符。因此，按此格式输入的日期无法正确识别为日期，导致错误计算。要保持日期作为公式一部分，请使用 DATE 函数，例如「DATE(1954;7;20)」或将日期放在引号内，使用 ISO 8601 标记法，例如「1954-07-20」。请避免使用受区域影响的日期格式，例如「07/20/54」，在其他区域设置下加载文档，会导致计算错误。

支持 ISO 8601 日期时间格式 (及其分隔符扩展格式) 的无歧义转换。如果出现 #VALUE! 错误，请在「LibreOffice - 偏好设置工具 - 选项
- LibreOffice Calc - 公式」「详细计算设置」区域的「详细信息...」 按钮，「文本转换为数字」列表框，取消选择「生成 #VALUE! 错误」。

### 示例

=WEEKNUM(DATE(1995;1;1);1) returns 1

=WEEKNUM(DATE(1995;1;1);2) returns 52. If the week starts on Monday, Sunday belongs to the last week of the previous year.

=WEEKNUM(DATE(1995;1;1);21) returns 52. Week 1 starts on Monday, 1995-01-02.

=WEEKNUM(DATE(1999;1;1);21) returns 53. Week 1 starts on Monday, 1999-01-04.