# Filter on @timestamp

**URL:** https://discuss.elastic.co/t/filter-on-timestamp/127748
**Category:** Kibana
**Created:** [April 12, 2018, 7:11am UTC](https://discuss.elastic.co/t/filter-on-timestamp/127748 "2018-04-12T07:11:13Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![krsna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krsna/32/30919_2.png) [@krsna](https://discuss.elastic.co/u/krsna)
#### Post date: [April 12, 2018, 7:11am UTC](https://discuss.elastic.co/t/filter-on-timestamp/127748/1 "2018-04-12T07:11:13Z")

</div>

Hello team,

There is some timeseries data in an index that is captured every 4 minutes. So there are 15 entries every hour. Below is the sample data.  
|@timestamp| No.of hits |  
|April 12th 2018, 09:00:00.000|36|  
|April 12th 2018, 09:04:00.000|37|  
|April 12th 2018, 09:08:00.000|34|  
|April 12th 2018, 09:12:00.000|36|  
|April 12th 2018, 09:16:00.000|39|  
|April 12th 2018, 09:20:00.000|37|  
|April 12th 2018, 09:24:00.000|36|  
|April 12th 2018, 09:28:00.000|38|  
|April 12th 2018, 09:32:00.000|37|  
|April 12th 2018, 09:36:00.000|37|

What I'm trying to do is get the data for the last 90 days so I use a range query. But I want to filter out the date so that I get hourly data and not in between entries. That is one entry per hour let's say at 8am, 9am, 10am etc... as below  
|@timestamp| No.of hits |  
|April 12th 2018, 09:00:00.000|36|  
|April 12th 2018, 10:00:00.000|42|  
|April 12th 2018, 11:00:00.000|55|  
|April 12th 2018, 12:00:00.000|38|

But the wild card or regex query will not filter @timestamp field. Can you tell me how to achieve this?

Thanks

---

<div class="post-metadata">

### Author: ![thomasneirynck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thomasneirynck/32/23313_2.png) [@thomasneirynck](https://discuss.elastic.co/u/thomasneirynck)
#### Post date: [April 13, 2018, 2:20pm UTC](https://discuss.elastic.co/t/filter-on-timestamp/127748/2 "2018-04-13T14:20:18Z")

</div>

hi @krsna,

I'd consider writing a scripted-field that turns your timestamp in a string-field or integer field with just the minutes. And then, when it is on the hour, you can filter on that scripted-field.

here's more info on scripted fields: [https://www.elastic.co/guide/en/kibana/current/scripted-fields.html](https://www.elastic.co/guide/en/kibana/current/scripted-fields.html)

You'll probably want to write a painless script. You can find out more info about that here:[https://www.elastic.co/guide/en/elasticsearch/painless/master/index.html](https://www.elastic.co/guide/en/elasticsearch/painless/master/index.html)

---

<div class="post-metadata">

### Author: ![krsna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krsna/32/30919_2.png) [@krsna](https://discuss.elastic.co/u/krsna)
#### Post date: [April 17, 2018, 6:56am UTC](https://discuss.elastic.co/t/filter-on-timestamp/127748/3 "2018-04-17T06:56:39Z")

</div>

ok Thomas, seems like a good workaround. I'll do it. Thank you.

---

<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: [May 15, 2018, 6:56am UTC](https://discuss.elastic.co/t/filter-on-timestamp/127748/4 "2018-05-15T06:56:54Z")

</div>

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