# Timelion filter data by hour

**URL:** https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948
**Category:** Kibana
**Tags:** timelion
**Created:** [May 15, 2018, 2:01pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948 "2018-05-15T14:01:22Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![RockD](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@RockD](https://discuss.elastic.co/u/RockD)
#### Post date: [May 15, 2018, 2:01pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/1 "2018-05-15T14:01:22Z")

</div>

Hi, I have the following problem, I need to compare the data of the current week with the past one, but the data I have to retrieve are only the ones that are between 10:00 AM to 2:00 PM.  
I tried with range(), but I get the error that the code is incorrect, If somebody have a clue how to accomplish this to track me to the correct path it will be appreciated.

regards

---

<div class="post-metadata">

### Author: ![lukas](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas/32/6812_2.png) [@lukas](https://discuss.elastic.co/u/lukas)
#### Post date: [May 15, 2018, 4:54pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/2 "2018-05-15T16:54:53Z")

</div>

Could you send a screenshot or copy/paste in here what you've got so far, and we can go from there? Thanks!

---

<div class="post-metadata">

### Author: ![RockD](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@RockD](https://discuss.elastic.co/u/RockD)
#### Post date: [May 15, 2018, 5:58pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/3 "2018-05-15T17:58:38Z")

</div>

sadly I didn't save the timelion, but what I want to do its something like this:  
`.es(q="@timestamp:[2017-01-01 TO 2018-02-11]")`

but with hour instead like

`.es(q="@timestamp:[10:00 TO 14:00]")` but it doesn't give any result

---

<div class="post-metadata">

### Author: ![timroes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timroes/32/19712_2.png) [@timroes](https://discuss.elastic.co/u/timroes)
#### Post date: [May 16, 2018, 7:03am UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/4 "2018-05-16T07:03:58Z")

</div>

Hi Rodrigo,

something like that is not possible in Elasticsearch. If you want to filter out for specific hours of the day, you need to either create a scripted field, that extracts the hour of the day from the actual `@timestamp` date field - but scripted fields won't work in timelion!

Even better - and faster - if you know you need to access these values for querying, you need to extract them before indexing, i.e. let your index infrastructure create a field, hourOfDay, that contains that numeric value. That's the only way how you can filter for those.

Cheers,  
Tim

---

<div class="post-metadata">

### Author: ![RockD](https://avatars.discourse-cdn.com/v4/letter/r/f6c823/32.png) [@RockD](https://discuss.elastic.co/u/RockD)
#### Post date: [May 16, 2018, 1:40pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/5 "2018-05-16T13:40:30Z")

</div>

Ow what a pity

@timroes thanks for the quick reply, and to give me a clue on how to circumvent this particular problem.

Thanks

Rod

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [June 13, 2018, 1:45pm UTC](https://discuss.elastic.co/t/timelion-filter-data-by-hour/131948/6 "2018-06-13T13:45:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
