---
title: hourSelection() function
description: hourSelection() filters rows by time values in a specified hour range.
url: https://docs.influxdata.com/flux/v0/stdlib/universe/hourselection/
estimated_tokens: 514
product: Flux
version: v0
publisher: InfluxData
canonical: https://docs.influxdata.com/flux/v0/stdlib/universe/hourselection/
date: '2024-04-08T16:01:02-06:00'
lastmod: '2024-04-08T16:01:02-06:00'
---

* Flux 0.39.0+

InfluxDB support

`hourSelection()` filters rows by time values in a specified hour range.

##### Function type signature

```js
(
    <-tables: stream[A],
    start: int,
    stop: int,
    ?location: {zone: string, offset: duration},
    ?timeColumn: string,
) => stream[A] where A: Record
```

For more information, see [Function type signatures](/flux/v0/function-type-signatures/).

## Parameters

### start

(Required)
First hour of the hour range (inclusive). Hours range from `[0-23]`.

### stop

(Required)
Last hour of the hour range (inclusive). Hours range from `[0-23]`.

### location

Location used to determine timezone. Default is the `location` option.

### timeColumn

Column that contains the time value. Default is `_time`.

### tables

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

## Examples

### Filter by business hours

```js
data
    |> hourSelection(start: 9, stop: 17)
```

[](#view-example-input-and-output)

View example input and output

#### Input data

|       \_time       |tag|\_value|
|--------------------|---|-------|
|2022-01-01T05:00:00Z|t1 |  \-2  |
|2022-01-01T09:00:10Z|t1 |  10   |
|2022-01-01T11:00:20Z|t1 |   7   |
|2022-01-01T16:00:30Z|t1 |  17   |
|2022-01-01T19:00:40Z|t1 |  15   |
|2022-01-01T20:00:50Z|t1 |   4   |

#### Output data

|       \_time       |tag|\_value|
|--------------------|---|-------|
|2022-01-01T09:00:10Z|t1 |  10   |
|2022-01-01T11:00:20Z|t1 |   7   |
|2022-01-01T16:00:30Z|t1 |  17   |

[transformations](/flux/v0/tags/transformations/)[date/time](/flux/v0/tags/date/time/)[filters](/flux/v0/tags/filters/)
| _time | tag | _value |
| --- | --- | --- |
| _time | tag | _value |
| 2022-01-01T05:00:00Z | t1 | -2 |
| 2022-01-01T09:00:10Z | t1 | 10 |
| 2022-01-01T11:00:20Z | t1 | 7 |
| 2022-01-01T16:00:30Z | t1 | 17 |
| 2022-01-01T19:00:40Z | t1 | 15 |
| 2022-01-01T20:00:50Z | t1 | 4 |

| _time | tag | _value |
| --- | --- | --- |
| _time | tag | _value |
| 2022-01-01T09:00:10Z | t1 | 10 |
| 2022-01-01T11:00:20Z | t1 | 7 |
| 2022-01-01T16:00:30Z | t1 | 17 |
