---
title: elapsed() function
description: elapsed() returns the time between subsequent records.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/elapsed/
estimated_tokens: 1420
product: Flux
version: v0
---

# elapsed() function

-   Flux 0.36.0+
-   View InfluxDB support

`elapsed()` returns the time between subsequent records.

For each input table, `elapsed()` returns the same table without the first row (because there is no previous time to derive the elapsed time from) and an additional column containing the elapsed time.

##### Function type signature

```js
(<-tables: stream[A], ?columnName: string, ?timeColumn: string, ?unit: duration) => stream[B] where A: Record, B: Record
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### unit

Unit of time used in the calculation. Default is `1s`.

### timeColumn

Column to use to compute the elapsed time. Default is `_time`.

### columnName

Column to store elapsed times in. Default is `elapsed`.

### tables

Input data. Default is piped-forward data (`<-`).

## Examples

### Calculate the time between points in seconds

```js
import "sampledata"

sampledata.int()
    |> elapsed(unit: 1s)
```

[](#view-example-input-and-output)

View example input and output

#### Input data

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | -2 | t1 |
| 2021-01-01T00:00:10Z | 10 | t1 |
| 2021-01-01T00:00:20Z | 7 | t1 |
| 2021-01-01T00:00:30Z | 17 | t1 |
| 2021-01-01T00:00:40Z | 15 | t1 |
| 2021-01-01T00:00:50Z | 4 | t1 |

| _time | _value | *tag |
| --- | --- | --- |
| 2021-01-01T00:00:00Z | 19 | t2 |
| 2021-01-01T00:00:10Z | 4 | t2 |
| 2021-01-01T00:00:20Z | -3 | t2 |
| 2021-01-01T00:00:30Z | 19 | t2 |
| 2021-01-01T00:00:40Z | 13 | t2 |
| 2021-01-01T00:00:50Z | 1 | t2 |

#### Output data

| _time | _value | *tag | elapsed |
| --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 10 | t1 | 10 |
| 2021-01-01T00:00:20Z | 7 | t1 | 10 |
| 2021-01-01T00:00:30Z | 17 | t1 | 10 |
| 2021-01-01T00:00:40Z | 15 | t1 | 10 |
| 2021-01-01T00:00:50Z | 4 | t1 | 10 |

| _time | _value | *tag | elapsed |
| --- | --- | --- | --- |
| 2021-01-01T00:00:10Z | 4 | t2 | 10 |
| 2021-01-01T00:00:20Z | -3 | t2 | 10 |
| 2021-01-01T00:00:30Z | 19 | t2 | 10 |
| 2021-01-01T00:00:40Z | 13 | t2 | 10 |
| 2021-01-01T00:00:50Z | 1 | t2 | 10 |

#### Related

-   [events.duration() function](/flux/v0/stdlib/contrib/tomhollingworth/events/duration/)

[transformations](/flux/v0/tags/transformations/)
