Documentation

Work with integers

An integer type represents a signed 64-bit integer.

Type name: int
Min value: -9223372036854775808
Max value: 9223372036854775807

Integer syntax

An integer literal contains one or more digits (0-9) optionally preceded by - to indicate a negative number. -0 is equivalent to 0 and is not a negative number.

0
2
1254
-1254

Convert data types to integers

Use the int() function to convert the following basic types to integers:

  • string: returns the integer equivalent of the numeric string ([0-9])
  • bool: returns 1 for true or 0 for false
  • duration: returns the number of nanoseconds in the duration
  • time: returns the equivalent nanosecond epoch timestamp
  • float: truncates the float value at the decimal
  • uint: returns the integer equivalent of the unsigned integer
int(v: "123")
// 123

int(v: true)
// Returns 1

int(v: 1d3h24m)
// Returns 98640000000000

int(v: 2021-01-01T00:00:00Z)
// Returns 1609459200000000000

int(v: 12.54)
// Returns 12

Round float values before converting to integers

When converting floats to integers, int() truncates the float value at the decimal (for example 12.54 to 12). You may want to round float values to the nearest whole number (12.54 to 13) before converting. To do this:

  1. Import the math package.
  2. Use math.round() to round the float value before converting it to an integer.
import "math"

int(v: math.round(x: 12.54))
// Returns 13

Convert a hexadecimal string to an integer

To convert a hexadecimal string representation of a number to an integer:

  1. Import the contrib/bonitoo-io/hex package.
  2. Use hex.int() to convert the hexadecimal string to an integer.
import "contrib/bonitoo-io/hex"

hex.int(v: "1e240")
// Returns 123456

Convert columns to integers

Flux lets you iterate over rows in a stream of tables and convert columns to integers.

To convert the _value column to integers, use the toInt() function.

toInt() only operates on the _value column.

data
    |> toInt()
Given the following input data:
_time_value (float)
2021-01-01T00:00:00Z1.23
2021-01-01T02:00:00Z4.56
2021-01-01T03:00:00Z7.89
2021-01-01T04:00:00Z10.11
The example above returns:
_time_value (int)
2021-01-01T00:00:00Z1
2021-01-01T02:00:00Z4
2021-01-01T03:00:00Z7
2021-01-01T04:00:00Z10

To convert any column to integers:

  1. Use map() to iterate over and rewrite rows.
  2. Use int() to convert columns values to integers.
data
    |> map(fn: (r) => ({ r with uid: int(v: r.uid) }))
Given the following input data:
_timeindex (string)
2021-01-01T00:00:00Z100010024
2021-01-01T02:00:00Z100050213
2021-01-01T03:00:00Z200130763
2021-01-01T04:00:00Z101420099
The example above returns:
_timeindex (int)
2021-01-01T00:00:00Z100010024
2021-01-01T02:00:00Z100050213
2021-01-01T03:00:00Z200130763
2021-01-01T04:00:00Z101420099

Operate on integers

Perform arithmetic operations on integers

To perform operations like adding, subtracting, multiplying, or dividing integers, use Flux arithmetic operators. Operands must be the same type. The operation returns an integer.

When operating with integer operands, fractional results are truncated at the decimal.

1 + 45
// Returns 46

1 - 45
// Returns -44

12 * 100
// Returns 1200

100 / 200
// Returns 0

10 ^ 2
// Returns 100

Perform bitwise operations on integers

Use the experimental/bitwise package to perform bitwise operations on integers.

import "experimental/bitwise"

bitwise.sand(a: 12, b: 21)
// Returns 4

bitwise.sor(a: 12, b: 21)
// Returns 29

bitwise.sxor(a: 12, b: 21)
// Returns 25

bitwise.sclear(a: 12, b: 21)
// Returns 8

bitwise.snot(a: 12)
// Returns -13

bitwise.slshift(a: 12, b: 21)
// Returns 25165824

bitwise.srshift(a: 21, b: 4)
// Returns 1

Compare integers

Use Flux comparison operators to compare integers. Operands must be the same type. The operation returns a boolean.

12345600 == 12345601
// Returns false

2 > -2
// Returns true

Was this page helpful?

Thank you for your feedback!


InfluxDB OSS 2.9.0: API tokens are hashed by default

Stronger token security in InfluxDB OSS 2.9.0 — tokens are hashed on disk by default. Existing tokens are hashed on first startup and can’t be recovered afterward. Capture any plaintext tokens you still need before you upgrade.

View InfluxDB OSS 2.9.0 release notes

Hashed tokens authenticate exactly like unhashed tokens — clients and integrations keep working.

Also new in 2.9.0:

  • Configurable backup compression
  • Restore support for backups containing hashed tokens
  • Tighter Edge Data Replication queue validation
  • Flux upgrade
  • Compaction reliability improvements

Key enhancements in Explorer 1.9

Explorer 1.9 is now available with InfluxQL support, an AI-assisted Flux to SQL converter (beta), and new live sample data simulators.

View Explorer 1.9 release notes

Explorer 1.9 includes new features and improvements that make it easier to query, visualize, and manage data.

Highlights:

  • Flux to SQL converter (beta): Convert Flux queries to SQL with an AI-assisted converter.
  • InfluxQL support: Query data with InfluxQL in the Data Explorer and dashboards, and save and load InfluxQL queries.
  • InfluxQL visualizations: Render line and bar charts from InfluxQL results with per-tag series grouping.
  • Query error history: Review a history of query errors in the query tool.
  • Live sample data simulators: Generate continuous live sample data with new bird data and signal generator simulators.

For more details, see Explorer 1.9 release notes

InfluxDB 3.10 is now available

InfluxDB 3 Core 3.10 adds an automatic catalog format upgrade, a configurable query-concurrency limit, and processing engine improvements.

Key updates in InfluxDB 3 Core 3.10:

  • Catalog format upgrade: the on-disk catalog automatically upgrades from format v2 to v3 on first 3.10 startup. Migration is one-way—back up your catalog before upgrading.
  • --max-concurrent-queries: limit concurrent queries (adjustable at runtime).
  • GET /ready endpoint for readiness probes.
  • Processing engine: cross-database queries and trigger lockdown flags.

For more information, see the InfluxDB 3 Core release notes.

InfluxDB 3.10 is now available

InfluxDB 3 Enterprise 3.10 adds automated backup and restore, row-level deletions, and user management, with an automatic catalog format upgrade and performance preview improvements.

Key updates in InfluxDB 3 Enterprise 3.10:

  • Catalog format upgrade: the on-disk catalog automatically upgrades from format v2 to v3 on first 3.10 startup. Migration is one-way—back up your catalog before upgrading.
  • Automated backup and restore (beta)
  • Row-level deletions
  • User management (authentication and RBAC) — preview
  • Performance preview improvements

Backup and restore, row-level deletions, and the performance preview require the Enterprise storage engine upgrade (opt-in beta). Beta and preview features are subject to breaking changes and aren’t recommended for production use.

For more information, see the InfluxDB 3 Enterprise release notes

Telegraf Enterprise is now generally available

Telegraf Enterprise is now generally available, along with Telegraf Controller v1.0.

Telegraf Enterprise combines Telegraf Controller, a centralized management console for Telegraf, with official support from InfluxData. Manage configurations, monitor fleet health, and operate tens of thousands of Telegraf agents from a single system.

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On September 15, 2026, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2