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

## [](#period1)period(period: { years?: Number, months?: Number, days?: Number }​): Period

ISO-8601 カレンダーシステムの日付ベースの年数、月数、日数として 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>period</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">​<code>{years:4, months:11, days:28}</code>​ などのオブジェクト。キー-値のペアは省略可能であり、任意の順序で指定できます。空のオブジェクト (​<code>{}</code>​) では、Period (期間) 値 ​<code>"P0D"</code>​ (0 日) を返します。各キーのデフォルト値は ​<code>0</code>​ です。有効な値は整数で、正でも負でも問題ありません。小数値ではエラーメッセージが表示されます。キー名は選択可能です。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、さまざまな入力での ​`period`​ の動作を示します。次の例では、DateTime (日時) 値および Date (日付) 値に対して ​`period`​ 関数の結果を減算および加算します。また、​`period`​ オブジェクトから Period (期間) 値を作成し、オブジェクトから ​`months`​ 値も選択します。

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

```DataWeave
%dw 2.0
output application/json
import * from dw::core::Periods
---
{
   dayBeforeDateTime: |2020-10-05T20:22:34.385Z| - period({days:1}),
   dayAfterDate: |2020-10-05| + period({days:1}),
   yearMonthDayAfterDate: |2020-10-05| + period({years:1, months:1, days:1}),
   emptyPeriod: period({}),
   constructPeriod: period({years:4, months:11, days:28}),
   selectMonthsFromPeriod: period({years:4, months:11, days:28}).months
}
```

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

```Json
{
    "dayBeforeDateTime": "2020-10-04T20:22:34.385Z",
    "dayAfterDate": "2020-10-06",
    "yearMonthDayAfterDate": "2021-11-06",
    "emptyPeriod": "P0D",
    "constructPeriod": "P4Y11M28D",
    "selectMonthsFromPeriod": 11
}
```