# Elastic search-ui: Date range filters not accepting custom dates

**URL:** <https://discuss.elastic.co/t/elastic-search-ui-date-range-filters-not-accepting-custom-dates/374834>\
**Category:** Elastic Search\
**Created:** [February 20, 2025, 7:57pm UTC](https://discuss.elastic.co/t/elastic-search-ui-date-range-filters-not-accepting-custom-dates/374834 "2025-02-20T19:57:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanza-s](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tanza-s/32/141330_2.png) [@tanza-s](https://discuss.elastic.co/u/tanza-s)\
**Post date:** [February 20, 2025, 7:57pm UTC](https://discuss.elastic.co/t/elastic-search-ui-date-range-filters-not-accepting-custom-dates/374834/1 "2025-02-20T19:57:40Z")

</div>

Hello,

I'm working on creating a custom component for a date range filter. On our applilcation, we need filters for "Today, This Week, Upcoming, Previous, and All," which I have specifically set up in the facet configuration as such:

```auto
"start_date_filter": {
    type: "range",
    ranges: [
        {
            from: moment().startOf("day").format('YYYY-MM-DD'),
            to: moment().endOf("day").format('YYYY-MM-DD'),
            name: "Today",
        },
...
    ],
}

```

In addition to this, I am creating a custom date range filter that uses Material's date picker input.

```auto
                    <DatePicker
                        defaultValue={moment().startOf("day")}
                        label="FROM"
                        onChange={(newValue) => {
                            setFilter(
                                "start_date-filter",
                                {
                                    from: from.format('YYYY-MM-DD'),
                                    name: from.format('YYYY-MM-DD')
                                },
                                "any")
                        }}
                    />

```

It successfully sends a request to the instance formatted as such:

```auto
filters: [{ 
    field: "start_date_filter",
    values: [{from: '2025-02-20', name: '2025-02-20'}]
}]

```

(I've also tried it without the 'name' field; no dice.)

However, my application doesn't filter from that date properly. I noticed that the only filter will accept are the named filters from the preset ranges, such as:

```auto
{field: "start_date_filter", values: ['Today']}

```

Is there a way that I can both create the preset ranges _and_ allow for the custom range set by the user? Do I need to set up some kind of function that adds the facet to the config or something?

---

<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 20, 2025, 7:57pm UTC](https://discuss.elastic.co/t/elastic-search-ui-date-range-filters-not-accepting-custom-dates/374834/2 "2025-03-20T19:57:54Z")

</div>

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