Documentation

truncateTimeColumn() function

The truncateTimeColumn() function truncates all input table _time values to a specified unit.

Function type: Transformation

truncateTimeColumn(unit: 1s)

Parameters

unit

The unit of time to truncate to.

Data type: Duration

Only use 1 and the unit of time to specify the unit. For example: 1s, 1m, 1h.

Examples

Truncate all time values to seconds
from(bucket:"example-bucket")
  |> range(start:-1h)
  |> truncateTimeColumn(unit: 1s)

Function definition

import "date"

truncateTimeColumn = (unit, tables=<-) =>
  tables
    |> map(fn: (r) => ({
        r with _time: date.truncate(t: r._time, unit:unit)
      })
    )

New! Cloud or OSS?

InfluxDB OSS 2.0 now generally available!

InfluxDB OSS 2.0 is now generally available and ready for production use. See the InfluxDB OSS 2.0 release notes.

For information about upgrading to InfluxDB OSS 2.0, see: