---
schema_version: "1"
id: 41fdf12d6d977a3c4cce23e19823679bc6fb0ea0a626433a805959974a30590c
title: toPeriod
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-coercions-functions-toperiod.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-coercions-functions-toperiod
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 84ddd5441a36aac5f91bced77a487a95ab771b61c460f892d4a9d366a281264f
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# 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|
}
```
