# Filter data in kibana based on begin date and end date

**URL:** <https://discuss.elastic.co/t/filter-data-in-kibana-based-on-begin-date-and-end-date/303905>\
**Category:** Kibana\
**Created:** [May 4, 2022, 7:19am UTC](https://discuss.elastic.co/t/filter-data-in-kibana-based-on-begin-date-and-end-date/303905 "2022-05-04T07:19:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alice\_Ionescu](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@Alice\_Ionescu](https://discuss.elastic.co/u/Alice_Ionescu)\
**Post date:** [May 4, 2022, 7:19am UTC](https://discuss.elastic.co/t/filter-data-in-kibana-based-on-begin-date-and-end-date/303905/1 "2022-05-04T07:19:51Z")

</div>

Hello,

I have a table with information and a begin date and an end date.  
I want to be able to filter data that are valid in the given interval.  
Do you have an idea on how to do this?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/0/8091ceb8bb6a2951a6c564c9ef1a89a66717fb89.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [May 4, 2022, 10:41am UTC](https://discuss.elastic.co/t/filter-data-in-kibana-based-on-begin-date-and-end-date/303905/2 "2022-05-04T10:41:53Z")

</div>

Because data views (previously index patterns) have just one date that is used for date range queries on any kibana application that shows the time filter, there is no direct way to do this that I can think of without removing the date from the data view.

Let me use an example:

First create an index with a text field and begin and end fields:

```auto
PUT delete_test_range
{
  "mappings": {
    "properties": {
      "id": {"type": "text"},
      "begin": {"type": "date"},
      "end": {"type": "date"}
    }
  }
}

PUT delete_test_range/_bulk
{ "index" : {}}
{ "id" : "doc1", "begin": "2020-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc2", "begin": "2020-01-01T12:22:44+0200", "end": "2023-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc3", "begin": "2021-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc4", "begin": "2022-01-01T12:22:44+0200", "end": "2022-05-04T12:22:51+0200" }
{ "index" : {}}
{ "id" : "doc5", "begin": "2022-01-05T12:22:44+0200", "end": "2022-08-04T12:22:51+0200" }

```

Then create a data view **without** a timestamp metadata:

 ![2022-05-04-12-34-46-screenshot](https://us1.discourse-cdn.com/elastic/original/3X/0/0/002f46b0e3eea7ebc15f595047bf70379fed02f3.png)

Now you can save a search in Discover to get your table ready for dashboards

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/a/8a7a3fb09c73cbb8d8f820645b1c238ee159da92.png)

And finally you can add in dashboard your search and use the filter pills to specify your interval because they compose toguether:

![Peek 2022-05-04 12-38](https://us1.discourse-cdn.com/elastic/original/3X/b/6/b6e76278e727e1b6c0fab0d28c8bf1c95d00cc39.gif)

If you check the **Inspect** tool of the saved search (available from the gear in the corner of the panel) you can see how Kibana builds the query using the filter pills

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/b/7b6861e4b5ac786d9e2f10970020d82ced132da7.png)

Hope it helps!

---

<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 1, 2022, 10:42am UTC](https://discuss.elastic.co/t/filter-data-in-kibana-based-on-begin-date-and-end-date/303905/3 "2022-06-01T10:42:32Z")

</div>

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