---
schema_version: "1"
id: c167990496d05cba830b0a66679210aced964b935601aaac16b4b3cabc93fb32
title: months
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.6/dw-periods-functions-months.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.6/dw-periods-functions-months
source_site: docs.mulesoft.com
content_type: documentation
content_hash: bc3c359f3eacab9d2b7d45f7914681a962342f7d5b7912471be0c9c43816ca83
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
# months

## [](#months1)months(nMonths: Number): Period

指定された月数から Period (期間) 値を作成します。

この関数では、​`period`​ 関数を入力値に適用します。

_DataWeave バージョン 2.4.0 で導入されました。_

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 75%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>nMonths</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">整数としての月数。
            正または負の数値が有効です。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`months`​ の動作を示します。 DateTime (日時) 値に 1 か月を加算し、整数 ​`4`​ を Period (期間) 形式の月数 (​`P4M`​) に変換します。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
import * from dw::core::Periods
output application/json
---
{
  nextMonth: |2020-10-05T20:22:34.385Z| + months(1),
  fourMonthPeriod : months(4),
  addNegativeValue: months(-1) + months(2)
}
```

#### [](#出力)出力

```Json
{
  "nextMonth": "2020-11-05T20:22:34.385Z",
  "fourMonthPeriod": "P4M",
  "addNegativeValue": 1
}
```