---
schema_version: "1"
id: 1f22d0ffb714dfd6d02620b8aa10b34edcbbcdb7cfdbecc8f2b8c0a1c2ea5075
title: toPeriod
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-coercions-functions-toperiod.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-coercions-functions-toperiod
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 896f7fa9d5890e145d5b87fa63076f3822192203744c7531ab88b766219fb797
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# toPeriod

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## toPeriod(str: String): Period

Transform a `String` value into a `Period` value.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>str</code></p></td><td><p>The <code>String</code> value to transform into a <code>Period</code> value.</p></td></tr></tbody></table>

### Example

This example shows how `toPeriod` behaves with different inputs. It produces output in the
`application/dw` format.

#### Source

```DataWeave
%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
  toPeriodEx1: toPeriod("P1D"),
  toPeriodEx2: toPeriod("PT1H1M")
}
```

#### Output

```Json
{
  toPeriodEx1: |P1D|,
  toPeriodEx2: |PT1H1M|
}
```
