int() function

Flux 0.7.0+

The int() function converts a single value to an integer.

Output data type: Integer

int(v: "4")



Value to convert.

int() behavior depends on the input data type:

Input typeReturned value
stringInteger equivalent of the numeric string
bool1 (true) or 0 (false)
durationNumber of nanoseconds in the specified duration
timeEquivalent nanosecond epoch timestamp
floatValue truncated at the decimal
uintInteger equivalent of the unsigned integer


Convert a string to an integer value

int(v: "3")

// Returns 3 (int)

Convert a boolean to an integer value

int(v: true)

// Returns 1

Convert a duration to an integer value

int(v: 1m)

// Returns 160000000000

Convert a time to an integer value

int(v: 2021-01-01T00:00:00Z)

// Returns 1609459200000000000

Convert a float to an integer value

int(v: 10.12)

// Returns 10

Convert all values in a column to integer values

If updating values in the _value column, use toInt(). To update values in columns other than _value:

  1. Use map() to iterate over and update all input rows.
  2. Use int() to update the value of a column.

The following example uses data provided by the sampledata package.

import "sampledata"

data = sampledata.float()
  |> rename(columns: {_value: "foo"})

  |> map(fn:(r) => ({ r with foo: int(v: }))

View input and output

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.