# LongMonthNames

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

语法：

LongMonthNames

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

LongMonthNames 函数的以下示例完整定义了月份名称：

`Set LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December';`

`LongMonthNames` 函数通常与以下功能结合使用：

相关函数

| 函数 | 交互 |
| --- | --- |
| [Date 脚本和图表功能](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/FormattingFunctions/Date.htm) | 脚本函数返回 `DayNames` 作为字段值。 |
| [LongDayNames](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Scripting/NumberInterpretationVariables/LongDayNames.htm) | 长形 `DayNames` 值。 |

## 区域设置

除非另有规定，本主题中的示例使用以下日期格式：MM/DD/YYYY。日期格式已经在数据加载脚本中的 `SET DateFormat` 语句中指定。由于区域设置和其他因素，系统中的默认日期格式可能有所不同。您可以更改以下示例中的格式以满足您的要求。或者，您可以更改加载脚本中的格式以匹配这些示例。有关更多信息，请参阅[修改应用程序和脚本的区域设置](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/Apps/regional-settings-in-apps.htm)。

应用程序中的默认区域设置基于用户配置文件。这些区域格式设置与 Qlik Cloud 用户界面中显示的语言无关。Qlik Cloud 将以与您使用的浏览器相同的语言显示。

如果你是应用程序创建者，你可以为自己创建的应用程序设置默认区域。有关更多信息，请参阅[设置 Qlik Cloud Analytics 中创建应用程序和脚本所用的首选区域设置](https://help.qlik.com/zh-CN/cloud-services/Subsystems/Hub/Content/Sense_Hub/UserInterface/Languages.htm#Setting)。

## 示例 1 – 系统变量默认值

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

#### 加载脚本和结果

概述

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

加载脚本包含：

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

* `date` 字段。

* 默认 `LongMonthNames` 定义。

加载脚本

```
SET LongMonthNames='January;February;March;April;May;June;July;August;September;October;November;December'; 
						
Transactions: 
Load 
date, 
Date(date,’MMMM’) 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 |

使用了默认 `LongMonthNames` 定义。在加载脚本中，要创建一个名为 `month` 的字段，`Date` 函数将与作为第一个参数的 `date` 字段结合使用。函数中的第二个参数是格式化 `MMMM`。

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

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

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

#### 加载脚本和结果

概述

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

加载脚本包含：

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

* `date` 字段。

* 修改后的 `LongMonthNames` 变量，以使用西班牙语中一周中的天数缩写。

加载脚本

```
SET LongMonthNames='Enero;Febrero;Marzo;Abril;Mayo;Junio;Julio;Agosto;Septiembre;OctubreNoviembre;Diciembre'; 

Transactions: 
LOAD 
date, 
Date(date,'MMMM') as monthname, 
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 
]; 
```

结果

加载数据并打开工作表。创建新表并将 `sum(amount)` 添加为度量，将这些字段添加为维度：

* `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 |

在加载脚本中，`LongMonthNames` 变量被修改，从而以西班牙语列出月份。然后，要创建一个名为 `monthname` 的字段，其为要结合作为第一个参数的 `date` 字段使用的 `Date` 函数。函数中的第二个参数是格式化 `MMMM`。

使用此格式 Qlik Sense 将第一个参数中的值转换为变量 `LongMonthNames` 中设置的相应整月名称。在结果表中，我们创建的字段 ` monthname  ` 的字段值显示以西班牙语写下的月份名称。