# Match date field on day in the month

**URL:** <https://discuss.elastic.co/t/match-date-field-on-day-in-the-month/283069>\
**Category:** Kibana\
**Created:** [September 1, 2021, 3:36pm UTC](https://discuss.elastic.co/t/match-date-field-on-day-in-the-month/283069 "2021-09-01T15:36:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![orly\_spivak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/orly_spivak/32/82233_2.png) [@orly\_spivak](https://discuss.elastic.co/u/orly_spivak)\
**Post date:** [September 1, 2021, 3:36pm UTC](https://discuss.elastic.co/t/match-date-field-on-day-in-the-month/283069/1 "2021-09-01T15:36:14Z")

</div>

Hey, I have a date type field that I wont to match by, and get all documents that the date field in them is the first day of the month.  
I tried regex but it does not work because it's not a string field.

I will be happy to find an answer (:

---

<div class="post-metadata">

**Author:** ![Nathan\_Reese](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nathan_reese/32/84829_2.png) [@Nathan\_Reese](https://discuss.elastic.co/u/Nathan_Reese)\
**Post date:** [September 2, 2021, 3:58pm UTC](https://discuss.elastic.co/t/match-date-field-on-day-in-the-month/283069/2 "2021-09-02T15:58:47Z")

</div>

You can create a [runtime field](https://www.elastic.co/guide/en/kibana/7.14/managing-index-patterns.html#runtime-fields) that returns the day of month. Then use this field for filter for first day of the month. You can also use this field for visualizing data by day month.

This is the script used to create a day of month runtime field from the date field timestamp

`emit(doc['timestamp'].value.getDayOfMonth());`

---

<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:** [September 30, 2021, 3:59pm UTC](https://discuss.elastic.co/t/match-date-field-on-day-in-the-month/283069/3 "2021-09-30T15:59:33Z")

</div>

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