truncateTimeColumn() function

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

*Function type: Transformation*

  1. 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
  1. from(bucket:"example-bucket")
  2. |> range(start:-1h)
  3. |> truncateTimeColumn(unit: 1s)

Function definition

  1. import "date"
  2. truncateTimeColumn = (unit, tables=<-) =>
  3. tables
  4. |> map(fn: (r) => ({
  5. r with _time: date.truncate(t: r._time, unit:unit)
  6. })
  7. )

Related articles