string() function

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

string(v: 123456789)



Value to convert.


Convert a boolean to a string value

string(v: true)

// Returns "true"

Convert a duration to a string value

string(v: 1m)

// Returns "1m"

Convert a time to a string value

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

// Returns "2021-01-01T00:00:00Z"

Convert a float to a string value

string(v: 10.12)

// Returns "10.12"

Convert all values in a column to string values

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

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

The following example uses data provided by the sampledata package.

import "sampledata"

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

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

View input and output

Upgrade to InfluxDB Cloud or InfluxDB 2.0!

InfluxDB Cloud and InfluxDB OSS 2.0 ready for production.