Back to Influxdb

toTime() function

content/flux/v0/stdlib/universe/totime.md

latest3.1 KB
Original Source
<!------------------------------------------------------------------------------ IMPORTANT: This page was generated from comments in the Flux source code. Any edits made directly to this page will be overwritten the next time the documentation is generated. To make updates to this documentation, update the function comments above the function definition in the Flux source code: https://github.com/influxdata/flux/blob/master/stdlib/universe/universe.flux#L4809-L4809 Contributing to Flux: https://github.com/influxdata/flux#contributing Fluxdoc syntax: https://github.com/influxdata/flux/blob/master/docs/fluxdoc.md ------------------------------------------------------------------------------->

toTime() converts all values in the _value column to time types.

Supported data types

  • string (RFC3339 timestamp)
  • int
  • uint

toTime() treats all numeric input values as nanosecond epoch timestamps.

Function type signature
js
(<-tables: stream[{A with _value: B}]) => stream[{A with _value: B, _value: time}]

{{% caption %}} For more information, see Function type signatures. {{% /caption %}}

Parameters

tables

Input data. Default is piped-forward data (<-).

Examples

Convert an integer _value column to times

js
data
    |> toTime()

{{< expand-wrapper >}} {{% expand "View example input and output" %}}

Input data

_time_value*tag
2021-01-01T00:00:00Z-20000000000000000t1
2021-01-01T00:00:10Z100000000000000000t1
2021-01-01T00:00:20Z70000000000000000t1
2021-01-01T00:00:30Z170000000000000000t1
2021-01-01T00:00:40Z150000000000000000t1
2021-01-01T00:00:50Z40000000000000000t1
_time_value*tag
2021-01-01T00:00:00Z190000000000000000t2
2021-01-01T00:00:10Z40000000000000000t2
2021-01-01T00:00:20Z-30000000000000000t2
2021-01-01T00:00:30Z190000000000000000t2
2021-01-01T00:00:40Z130000000000000000t2
2021-01-01T00:00:50Z10000000000000000t2

Output data

_time_value*tag
2021-01-01T00:00:00Z1969-05-14T12:26:40Zt1
2021-01-01T00:00:10Z1973-03-03T09:46:40Zt1
2021-01-01T00:00:20Z1972-03-21T04:26:40Zt1
2021-01-01T00:00:30Z1975-05-22T14:13:20Zt1
2021-01-01T00:00:40Z1974-10-03T02:40:00Zt1
2021-01-01T00:00:50Z1971-04-08T23:06:40Zt1
_time_value*tag
2021-01-01T00:00:00Z1976-01-09T01:46:40Zt2
2021-01-01T00:00:10Z1971-04-08T23:06:40Zt2
2021-01-01T00:00:20Z1969-01-18T18:40:00Zt2
2021-01-01T00:00:30Z1976-01-09T01:46:40Zt2
2021-01-01T00:00:40Z1974-02-13T15:06:40Zt2
2021-01-01T00:00:50Z1970-04-26T17:46:40Zt2

{{% /expand %}} {{< /expand-wrapper >}}