uint() function
The uint()
function converts a single value to a UInteger.
uint(v: "4")
Parameters
v
The value to convert.
uint()
behavior depends on the input data type:
Input type | Returned value |
---|---|
bool | 1 (true) or 0 (false) |
duration | Number of nanoseconds in the specified duration |
float | UInteger equivalent of the float value truncated at the decimal |
int | UInteger equivalent of the integer |
string | UInteger equivalent of the numeric string |
time | Equivalent nanosecond epoch timestamp |
Examples
- Convert a string to a uinteger value
- Convert a boolean to a uinteger value
- Convert a duration to a uinteger value
- Convert a time to a uinteger value
- Convert a float to a uinteger value
- Convert all values in a column to uinteger values
Convert a string to a uinteger value
uint(v: "3")
// Returns 3 (uint)
Convert a boolean to a uinteger value
uint(v: true)
// Returns 1
Convert a duration to a uinteger value
uint(v: 1m)
// Returns 160000000000
Convert a time to a uinteger value
uint(v: 2021-01-01T00:00:00Z)
// Returns 1609459200000000000
Convert a float to a uinteger value
uint(v: 10.12)
// Returns 10
Convert all values in a column to uinteger values
If updating values in the _value
column, use toUInt()
.
To update values in columns other than _value
:
- Use
map()
to iterate over and update all input rows. - Use
uint()
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"})
data
|> map(fn: (r) => ({r with foo: uint(v: r.foo)}))
Was this page helpful?
Thank you for your feedback!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for Flux and this documentation. To find support, use the following resources:
InfluxDB Cloud customers can contact InfluxData Support.