# Help me to refine this query

**URL:** <https://discuss.elastic.co/t/help-me-to-refine-this-query/244023>\
**Category:** Logstash\
**Tags:** painless\
**Created:** [August 6, 2020, 12:48pm UTC](https://discuss.elastic.co/t/help-me-to-refine-this-query/244023 "2020-08-06T12:48:01Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [August 7, 2020, 3:29am UTC](https://discuss.elastic.co/t/help-me-to-refine-this-query/244023/4 "2020-08-07T03:29:49Z")

</div>

> [@pk.241011](#):
>
> but it did not work:

What did it do? This should give you the documents between midnight of the day before and midnight today. (I don't know why the format parameter is there when only relative times are used in the query, so the format isn't used anywhere?)

> [@pk.241011](#):
>
> But `now` still had the time part

What do you mean?

> [@pk.241011](#):
>
> Is there any way to round off `now` to nearest hour

You could use `/h` instead of `/d` to round down to the hour instead of the day. That is explained in the [date math](https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#date-math) documentation that is linked in the article mentioned above.

* * *

Edit: As a side note: You could have mentioned that you've already got a topic for this. Didn't setting the `time_zone` help?

> [@How to fix this date range](https://discuss.elastic.co/t/how-to-fix-this-date-range/243065):
>
> Hi, Here is sample code from the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html#ranges-on-dates): GET /\_search { "query": { "range": { "timestamp": { "gte": "now-1d/d", "lt": "now/d" } } } } I want to change it so that now only uses the date part and not the time. My usecase is to get previous day data for 24 hours e.g Between 00:00:00 and 23:59:59. In other words the range should be [28-07-2020 to 29-07-2020]. Is there any extension on now like now.Date? I was looking at painless script but not su…

---

_[View the full topic](https://discuss.elastic.co/t/help-me-to-refine-this-query/244023)._
