duration() function

The duration() function converts a single value to a duration.

Function type: Type conversion
Output data type: Duration

duration(v: "1m")



The value to convert.

Data type: Integer | String | Uinteger

duration() assumes numeric input values are nanoseconds. String input values must use duration literal representation.


Flux does not support duration column types. The example below converts an integer to a duration and stores the value as a string.

from(bucket: "sensor-data")
  |> range(start: -1m)
  |> filter(fn:(r) => r._measurement == "system" )
  |> map(fn:(r) => ({ r with uptime: string(v: duration(v: r.uptime)) }))

Set your InfluxDB URL

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.