# MonthNames

定义的格式会替换地区设置的月名称惯例。

语法：

MonthNames

修改变量时，需要使用 `;` 分隔各个值。

函数示例

| 示例 | 结果 |
| --- | --- |
| ` Set MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';  ` | 此 `MonthNames` 函数的使用定义了英文月份名称及其缩写形式。 |
| ` Set MonthNames='Enero;Feb;Marzo;Abr;Mayo;Jun;Jul;Agosto;Set;Oct;Nov;Dic';  ` | 此 ` MonthNames  ` 函数的使用定义了西班牙语的月份名称及其缩写形式。 |

`MonthNames` 函数可与以下函数结合使用：

相关函数

| 函数 | 交互 |
| --- | --- |
| [month - 脚本和图表功能](https://help.qlik.com/zh-CN/sense/November2025/Subsystems/Hub/Content/Sense_Hub/Scripting/DateAndTimeFunctions/month.htm) | 脚本函数返回 `MonthNames` 中定义的值作为字段值 |
| [Date - 脚本和图表功能](https://help.qlik.com/zh-CN/sense/November2025/Subsystems/Hub/Content/Sense_Hub/Scripting/FormattingFunctions/Date.htm) | 脚本函数，用于根据提供的格式化参数返回 `MonthNames` 中定义为字段值的值 |
| [LongMonthNames](https://help.qlik.com/zh-CN/sense/November2025/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/LongMonthNames.htm) | `MonthNames` 的长形值 |

## 区域设置

除非另有规定，本主题中的示例使用以下日期格式：MM/DD/YYYY。日期格式已经在数据加载脚本中的 `SET DateFormat` 语句中指定。由于区域设置和其他因素，系统中的默认日期格式可能有所不同。您可以更改以下示例中的格式以满足您的要求。或者，您可以更改加载脚本中的格式以匹配这些示例。

应用程序中的默认区域设置基于安装 Qlik Sense 的计算机或服务器的区域系统设置。如果您访问的 Qlik Sense 服务器设置为瑞典，则数据加载编辑器将使用瑞典地区设置的日期、时间和货币。这些区域格式设置与 Qlik Sense 用户界面中显示的语言无关。Qlik Sense 将以与您使用的浏览器相同的语言显示。

## 1 – 系统变量默认值

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/MonthNames.htm)

#### 加载脚本和结果

概述

打开数据加载编辑器，并将下面的加载脚本添加到新部分。

加载脚本包含：

* 加载到名为 `Transactions` 的表中的日期数据集。

* `date` 字段。

* 默认 `MonthNames` 定义。

加载脚本

```
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec'; 

Transactions: 
LOAD 
date, 
Month(date) as monthname, 
id, 
amount 
INLINE  
[ 
date,id,amount 
01/01/2022,1,1000.45 
01/02/2022,2,2123.34 
01/03/2022,3,4124.35 
01/04/2022,4,2431.36 
01/05/2022,5,4787.78
01/06/2022,6,2431.84 
01/07/2022,7,2854.83 
01/08/2022,8,3554.28 
01/09/2022,9,3756.17 
01/10/2022,10,3454.35 
]; 
```

结果

加载数据并打开工作表。创建新表并将这些字段添加为维度：

* `date`
* `monthname`

创建该度量：

`=sum(amount)`

结果表

| 日期 | monthname | sum(amount) |
| --- | --- | --- |
| 01/01/2022 | 一月 | 1000.45 |
| 01/02/2022 | 一月 | 2123.34 |
| 01/03/2022 | 一月 | 4124.35 |
| 01/04/2022 | 一月 | 2431.36 |
| 01/05/2022 | 一月 | 4787.78 |
| 01/06/2022 | 一月 | 2431.84 |
| 01/07/2022 | 一月 | 2854.83 |
| 01/08/2022 | 一月 | 3554.28 |
| 01/09/2022 | 一月 | 3756.17 |
| 01/10/2022 | 一月 | 3454.35 |

使用了默认 `MonthNames` 定义。在加载脚本中，`  Month ` 函数与 `date` 字段一起用作提供的参数。

在结果表中，此 `Month` 函数的输出以 `MonthNames` 定义的格式显示一年中的月份。

## 示例 2 – 更改系统变量

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/MonthNames.htm)

#### 加载脚本和结果

概述

打开数据加载编辑器，并将下面的加载脚本添加到新部分。

加载脚本包含：

* 加载到名为 `Transactions` 的表中的日期数据集。

* `date` 字段。

* 修改后的 ` MonthNames  ` 变量，以使用西班牙语的缩写月份。

加载脚本

```

                            Set MonthNames='Enero;Feb;Marzo;Abr;Mayo;Jun;Jul;Agosto;Set;Oct;Nov;Dic'; 

Transactions: 
LOAD 
date, 
month(date) as month, 
id, 
amount 
INLINE  
[ 
date,id,amount 
01/01/2022,1,1000 
02/01/2022,2,2123 
03/01/2022,3,4124 
04/01/2022,4,2431 
]; 
```

结果

加载数据并打开工作表。创建新表并将这些字段添加为维度：

* `date`
* `monthname`

创建该度量：

`=sum(amount)`

结果表

| 日期 | monthname | sum(amount) |
| --- | --- | --- |
| 01/01/2022 | Enero | 1000.45 |
| 01/02/2022 | Enero | 2123.34 |
| 01/03/2022 | Enero | 4124.35 |
| 01/04/2022 | Enero | 2431.36 |
| 01/05/2022 | Enero | 4787.78 |
| 01/06/2022 | Enero | 2431.84 |
| 01/07/2022 | Enero | 2854.83 |
| 01/08/2022 | Enero | 3554.28 |
| 01/09/2022 | Enero | 3756.17 |
| 01/10/2022 | Enero | 3454.35 |

在加载脚本中，首先 `MonthNames` 变量被修改，从而以西班牙语缩写列出年中月份。`Month` 函数与 `date` 字段一起用作提供的参数。

在结果表中，此 `Month` 函数的输出以 `MonthNames` 定义的格式显示一年中的月份。

重要的是要记住，如果对 `MonthNames` 变量的语言进行了修改，如本例中所示，则 `LongMonthNames` 变量仍将包含英文的一年的月份。如果应用程序中同时使用两个变量，则必须修改 `LongMonthNames` 变量。

## 示例 3 – 日期函数

[](https://help.qlik.com/en-US/sense/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/MonthNames.htm)

#### 加载脚本和结果

概述

打开数据加载编辑器，并将下面的加载脚本添加到新部分。

加载脚本包含：

* 加载到名为 `Transactions` 的表中的日期数据集。

* `date` 字段。

* 默认 `MonthNames` 定义。

加载脚本

```
SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec'; 

Transactions: 
LOAD 
date, 
Month(date, ’MMM’) as monthname, 
id, 
amount 
INLINE  
[ 
date,id,amount 
01/01/2022,1,1000.45 
01/02/2022,2,2123.34 
01/03/2022,3,4124.35 
01/04/2022,4,2431.36 
01/05/2022,5,4787.78 
01/06/2022,6,2431.84 
01/07/2022,7,2854.83 
01/08/2022,8,3554.28 
01/09/2022,9,3756.17 
01/10/2022,10,3454.35 
]; 
```

结果

加载数据并打开工作表。创建新表并将这些字段添加为维度：

* `date`
* `monthname`

创建该度量：

`=sum(amount)`

结果表

| 日期 | monthname | sum(amount) |
| --- | --- | --- |
| 01/01/2022 | 一月 | 1000.45 |
| 01/02/2022 | 一月 | 2123.34 |
| 01/03/2022 | 一月 | 4124.35 |
| 01/04/2022 | 一月 | 2431.36 |
| 01/05/2022 | 一月 | 4787.78 |
| 01/06/2022 | 一月 | 2431.84 |
| 01/07/2022 | 一月 | 2854.83 |
| 01/08/2022 | 一月 | 3554.28 |
| 01/09/2022 | 一月 | 3756.17 |
| 01/10/2022 | 一月 | 3454.35 |

使用了默认 `MonthNames` 定义。在加载脚本中， `Date` 函数与 `date` 字段一起用作第一个参数。第二个参数为 `MMM`。

使用此格式 Qlik Sense 将第一个参数中的值转换为变量 `MonthNames` 中设置的相应月名称。在结果表中，我们创建的字段 `month` 的字段值显示此项。