---
schema_version: "1"
id: 22b4a4fa17cda63be57e5cd26d0aae401755ddbe8a41c0798f9e2c2c42435ef7
title: months
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-periods-functions-months.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-periods-functions-months
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 20b8d0db8e7ec6aaf7ca64d04f161fee5b9fb5b70d274992860b2f48de2e3524
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

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