# Date range search from the 25th of the month to now

**URL:** <https://discuss.elastic.co/t/date-range-search-from-the-25th-of-the-month-to-now/217668>\
**Category:** Elasticsearch\
**Created:** [February 3, 2020, 6:09pm UTC](https://discuss.elastic.co/t/date-range-search-from-the-25th-of-the-month-to-now/217668 "2020-02-03T18:09:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![npahucki](https://avatars.discourse-cdn.com/v4/letter/n/b3f665/32.png) [@npahucki](https://discuss.elastic.co/u/npahucki)\
**Post date:** [February 3, 2020, 6:09pm UTC](https://discuss.elastic.co/t/date-range-search-from-the-25th-of-the-month-to-now/217668/1 "2020-02-03T18:09:01Z")

</div>

Using a range query, it's easy to search from the 1st of the month until now. However, I need to create an alert that aggregates date from the 25th of the month to now. For example, if today is the Jan 24, then I want data from Dec 25th to Jan24. But if today is Jan 26th, then I want data from Jan 25 to Jan 26th.

I can't do (((now/M)-1M)+25d) as this won't work between the 26th and the 1st of the next month.

I can't think if a way to do this using date math - is there a way? If not what other alternatives are there? Could I figure out the last 25th in a scripted field and that use that in the range query somehow?

---

<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:** [March 2, 2020, 6:09pm UTC](https://discuss.elastic.co/t/date-range-search-from-the-25th-of-the-month-to-now/217668/2 "2020-03-02T18:09:07Z")

</div>

Closed on March 2, 2020, 6:09pm UTC

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