# Query to fetch data for current month

**URL:** <https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034>\
**Category:** Kibana\
**Created:** [April 28, 2023, 9:09am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034 "2023-04-28T09:09:26Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [April 28, 2023, 9:09am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/1 "2023-04-28T09:09:26Z")

</div>

Hi all,

I'm trying to fetch data only for current month of april 2023.

For example,

I have a query filter condition in my search bar in my kibana data table as

`configuredDate > now-30d`

which gives me data for past 1 month.

But I want to fetch data from April 1st to April 28th 2023.  
The above query fetches me data from March 30th 2023 to April 28th 2023.

I want to fetch data from 1st of the current month to current date for other queries.  
This data may dynamic , but i want to fetch from 1st of current month i.e from April 1st 2023 to April 28th 2023 or current timestamp.

Any way to go about it?

Regards

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [April 28, 2023, 9:30am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/2 "2023-04-28T09:30:29Z")

</div>

Hello @Sandeep_Raju

You can try the below steps

1.Click on the quickselect icon  
2. change to Absolute there you can mention the date you want

Refer the below screenshot

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/f/df7d07a01a1cec9140ea8a639298ad2a0fcfbdda.png)

---

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [April 28, 2023, 9:36am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/3 "2023-04-28T09:36:09Z")

</div>

I'm using different queries in a single dashboard, so using Timepicker from timeframe is not possible as shown in below .

I cannot change in timeframe. It has to be within visualization.

 ![Screenshot 2023-04-28 at 3.04.57 PM](https://us1.discourse-cdn.com/elastic/original/3X/5/9/59ff28ec660aa8e02f2460158408219bdc2aebb6.png)

Any ideas

---

<div class="post-metadata">

**Author:** ![sudhagar\_ramesh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sudhagar_ramesh/32/105673_2.png) [@sudhagar\_ramesh](https://discuss.elastic.co/u/sudhagar_ramesh)\
**Post date:** [April 28, 2023, 11:16am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/4 "2023-04-28T11:16:45Z")

</div>

Could you try this query and feedback

configuredDate \>= "2023-04-01T00:00:00" AND configuredDate \<= "now"

---

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [April 28, 2023, 11:28am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/5 "2023-04-28T11:28:50Z")

</div>

No, it has to be dynamic.  
For example if I'm in May, it should show from May 01, 2023 to now

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [April 28, 2023, 4:34pm UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/6 "2023-04-28T16:34:31Z")

</div>

> [@Sandeep\_Raju](#):
>
> No, it has to be dynamic.  
> For example if I'm in May, it should show from May 01, 2023 to now

There is no easy way to do that...

What I have done to get something similar is use Lens:

For each visualization

Histogram is set to monthly

Then for Last Month Visualizations use the shift=1M in the metric calculation

Set the dashboard Time Picker to 31 Days or so.. or setup up customer quick picks via under Kibana Advanced settings...

Not perfect but may get you closer.

I have a dashboard that shows a year with Each Month and some Month Over Month this is how I do it... not exactly the same as yours but best I could do.

---

<div class="post-metadata">

**Author:** ![Sandeep\_Raju](https://avatars.discourse-cdn.com/v4/letter/s/8797f3/32.png) [@Sandeep\_Raju](https://discuss.elastic.co/u/Sandeep_Raju)\
**Post date:** [May 5, 2023, 11:16am UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/7 "2023-05-05T11:16:56Z")

</div>

I tried in DSL query filter and it worked as below:

```auto
{
  "query": {
    "range": {
      "configuredDate": {
        "gte": "now/M"
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 5, 2023, 1:33pm UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/8 "2023-05-05T13:33:04Z")

</div>

@Sandeep_Raju  
Nicely done!

Makes sense now that I see it, I'll put that in my bag of tricks.

Today I Learned!

---

<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 2, 2023, 1:33pm UTC](https://discuss.elastic.co/t/query-to-fetch-data-for-current-month/331034/9 "2023-06-02T13:33:35Z")

</div>

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