---
schema_version: "1"
id: 419bc24d311b952c24f825dcbddf2397d04f54aa370fbc4a6aaf46d62a98a840
title: period
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.7/dw-periods-functions-period.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.7/dw-periods-functions-period
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 154b57c46c6a3c7b45310018f441b53267ae8b8e7009b1318428fa12d7c7d13e
description: MuleSoft Documentation Site
release: "2.7"
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
}
```