# Keep the hour range and set the day dynamically

**URL:** <https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language, visualisation\
**Created:** [June 5, 2025, 1:44pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922 "2025-06-05T13:44:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torado](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Torado](https://discuss.elastic.co/u/Torado)\
**Post date:** [June 5, 2025, 1:44pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/1 "2025-06-05T13:44:04Z")

</div>

Hello everyone,

I've search for a long time, unfortunately I can't found any solution.  
Is it any way to set dynamically the day but keeping the date range fix when I creat a Kibana visualisation ? (I don't have access to the Elasticsearch, only to the Kibana interface).

For more context :  
I want to extract statistics using a verticalbars visualisation, these statistics are day by day statistics but the time range stay always fix, (for example 6AM-2PM, 2PM-10PM). So I wish to keep this hour range fix but that every day the date change automaticly.

Did you know if this is possible ? (I'm not effraid to use Query DSL filter if needed)

Thanks to all those who will try to help me. 🙂

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [June 5, 2025, 2:40pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/2 "2025-06-05T14:40:30Z")

</div>

Suggestion: Runtime fields (eg hour of day extracted from your timestamp). Then filter on that ?

(Might be expensive)

---

<div class="post-metadata">

**Author:** ![Marco\_Liberati](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marco_liberati/32/82953_2.png) [@Marco\_Liberati](https://discuss.elastic.co/u/Marco_Liberati)\
**Post date:** [June 5, 2025, 3:01pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/3 "2025-06-05T15:01:33Z")

</div>

Using ES|QL it looks something like this (for the 6AM to 2PM case):

```auto
FROM my_index  
  | WHERE @timestamp <=?_tend and @timestamp >?_tstart
  | STATS count = COUNT(*) BY OverTime = BUCKET(@timestamp, 100, ?_tstart, ?_tend)
  | WHERE DATE_EXTRACT("hour_of_day", OverTime) > 5
    AND DATE_EXTRACT("hour_of_day", OverTime) <= 14

```

Is that what you are looking for?  
Mind that ES|QL currently works with UTC only, so tweak that accordingly.

---

<div class="post-metadata">

**Author:** ![Torado](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Torado](https://discuss.elastic.co/u/Torado)\
**Post date:** [June 5, 2025, 3:14pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/4 "2025-06-05T15:14:37Z")

</div>

Thank you for your answers 🙂

I'll do some test and come back to you with feedback

---

<div class="post-metadata">

**Author:** ![Torado](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Torado](https://discuss.elastic.co/u/Torado)\
**Post date:** [June 6, 2025, 12:31pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/5 "2025-06-06T12:31:27Z")

</div>

Hello,

Just to let you know, for now I didn't have the right to use ES|QL. I'm discussing with the stack holder to have the rights; else I will have to find another way or just drop this idea.

---

<div class="post-metadata">

**Author:** ![RainTown](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/raintown/32/140206_2.png) [@RainTown](https://discuss.elastic.co/u/RainTown)\
**Post date:** [June 9, 2025, 11:24am UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/6 "2025-06-09T11:24:26Z")

</div>

how did you get on?

Another idea, though maybe you won't have rights for it, would be to use an ingest pipeline to add the fields you want to aggregate on, eg hourOfDay, maybe also dayOfWeek, dayOfMonth, etc. These are simple extractions form the timestamp field, similar to the DATE\_EXTRACT ESQL function. Obviously, if implemented, would only help with newly indexed data but ... another idea at least.

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [June 9, 2025, 12:15pm UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/7 "2025-06-09T12:15:44Z")

</div>

Hello @Torado

Adding one more idea to the list if it works for you :

> [@Two different controls to be applied on two separate visualizations on one dashboard](https://discuss.elastic.co/t/two-different-controls-to-be-applied-on-two-separate-visualizations-on-one-dashboard/378943/4):
>
> Hello @rubic Could you please confirm if you want to compare data for any specific range? Like if we want to compare can use below logic : Step 1 : Add similar metric for comparison - Step 2 : for the second metric use below configuration , use timeshift as per your need 1d,1w,1m So in same graph it compares count of today with yesterday. Hope it helps. Thanks!!

Thanks!!

---

<div class="post-metadata">

**Author:** ![Torado](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Torado](https://discuss.elastic.co/u/Torado)\
**Post date:** [June 10, 2025, 8:56am UTC](https://discuss.elastic.co/t/keep-the-hour-range-and-set-the-day-dynamically/378922/8 "2025-06-10T08:56:58Z")

</div>

Hello @Tortoise and @RainTown !

First sorry for the response time, yesteday was a day off in my country.

For now I can't use ES|QL because the stack is in a older version where (from the stack holder) the feature is not stable, so he didn't enable it but he plan to update the stack in near future so I will be able to test in few time.

For you two new idea I will tried it and come back to you thanks 🙂
