---
schema_version: "1"
id: 645331f5c4f50d7518ed9d3856e4b0d72607598fd40b136ea428b63b077f08a0
title: months
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.9/dw-periods-functions-months.md
canonical_url: https://docs.mulesoft.com/dataweave/2.9/dw-periods-functions-months
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 10246b337b03e21344b28bae3e6a71da6fcc93740c1119061a1bca897626cc9f
description: MuleSoft Documentation Site
release: "2.9"
latest: false
---
---
product: DataWeave
version: 2.9
---

# months

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

## months(nMonths: Number): Period

Creates a Period value from the provided number of months.

The function applies the `period` function to the input 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>nMonths</code></p></td><td><p>The number of months as a whole number. A positive or negative number is valid.</p></td></tr></tbody></table>

### Example

This example shows how `months` behaves with different inputs. It adds a month to a DateTime value,
and it converts the whole number `4` to a number of months in the Period format (`P4M`).

#### Source

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

#### Output

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