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

# seconds

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

## seconds(nSecs: Number): Period

Creates a Period value from the provided number of seconds.

_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>nSecs</code></p></td><td><p>The number of seconds as a whole or decimal number. A positive or negative number is valid.</p></td></tr></tbody></table>

### Example

This example shows how `seconds` behaves with different inputs. It adds and subtracts seconds from
DateTime values. It also converts the decimal value `4.555` into the Period format (`PT4.555S`) and
and the whole number `4` into the Period format (`PT4S`)

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Periods
output application/json
---
{
  nextSecond: |2020-10-05T20:22:34.385Z| + seconds(1),
  previousSecond: |2020-10-05T20:22:34.385Z| - seconds(1),
  decimalInputPeriod: seconds(4.555),
  wholeNumberInputPeriod: seconds(4),
  addNegativeValue: seconds(-1) + seconds(2)
}
```

#### Output

```Json
{
  "nextSecond": "2020-10-05T20:22:35.385Z",
  "previousSecond": "2020-10-05T20:22:33.385Z",
  "decimalInputPeriod": "PT4.555S",
  "wholeNumberInputPeriod": "PT4S",
  "addNegativeValue": 1
}
```
