content/flux/v0/stdlib/experimental/aligntime.md
experimental.alignTime() shifts time values in input tables to all start at a common start time.
(<-tables: stream[B], ?alignTo: A) => stream[C] where B: Record, C: Record
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Time to align tables to. Default is 1970-01-01T00:00:00Z.
Input data. Default is piped-forward data (<-).
2021-01-01T00:00:00Z.Each output table represents data from a calendar month. When visualized, data is still grouped by month, but timestamps are aligned to a common start time and values can be compared by time.
import "experimental"
data
|> window(every: 1mo)
|> experimental.alignTime(alignTo: 2021-01-01T00:00:00Z)
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
| *_start | *_stop | _time | _value |
|---|---|---|---|
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-01T00:00:00Z | 38.3 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-02T00:00:00Z | 38.4 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-03T00:00:00Z | 37.8 |
| 2021-01-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-02-04T00:00:00Z | 37.5 |
| *_start | *_stop | _time | _value |
|---|---|---|---|
| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-01T00:00:00Z | 32.1 |
| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-02T00:00:00Z | 32.9 |
| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-03T00:00:00Z | 33.2 |
| 2021-01-01T00:00:00Z | 2021-02-01T00:00:00Z | 2021-01-04T00:00:00Z | 34 |
| *_start | *_stop | _time | _value |
|---|---|---|---|
| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-01T00:00:00Z | 38.3 |
| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-02T00:00:00Z | 38.4 |
| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-03T00:00:00Z | 37.8 |
| 2021-02-01T00:00:00Z | 2021-03-01T00:00:00Z | 2021-01-04T00:00:00Z | 37.5 |
{{% /expand %}} {{< /expand-wrapper >}}