# Custom Date range selectors

**URL:** <https://discuss.elastic.co/t/custom-date-range-selectors/226567>\
**Category:** Kibana\
**Created:** [April 5, 2020, 11:34am UTC](https://discuss.elastic.co/t/custom-date-range-selectors/226567 "2020-04-05T11:34:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwardj3](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@edwardj3](https://discuss.elastic.co/u/edwardj3)\
**Post date:** [April 5, 2020, 11:34am UTC](https://discuss.elastic.co/t/custom-date-range-selectors/226567/1 "2020-04-05T11:34:04Z")

</div>

Hi community,  
Had Data Analyst training this week and I asked if there were options to add the following to date picker section:-

- Yesterday
- Last Week
- Last Month
- This Week
- This Month

I was advised that this could not be done. However, I found these previous posts  
[How to create a custom time range for Last Month in kibana](https://discuss.elastic.co/t/how-to-create-a-custom-time-range-for-last-month-in-kibana/166740/3) &  
[Time Filter for the current month](https://discuss.elastic.co/t/time-filter-for-the-current-month/215361/3)  
threads.

As a newby to Kibana and coding in general would I just replace the M with D for Day and W for Week to create what I require. Example for yesterday below?

```auto
   {
   "from": "now/D-1D",
   "to": "now-1D/D",
   "display": "Yesterday (Custom)",
   "section": 1
   }

```

---

<div class="post-metadata">

**Author:** ![mattiacareddu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattiacareddu/32/60917_2.png) [@mattiacareddu](https://discuss.elastic.co/u/mattiacareddu)\
**Post date:** [April 5, 2020, 1:58pm UTC](https://discuss.elastic.co/t/custom-date-range-selectors/226567/2 "2020-04-05T13:58:35Z")

</div>

You can use the following for last week / last month:

```
{
    "from": "now-1w", #replace with -1m for month
    "to": "now",
    "display": "Last 1 week"
}

```

Instead for this week and this month you do something like this:

```
{
    "from": "now/w", #replace with M for month
    "to": "now/w", # replace with M for month
    "display": "This week"
} 

```

Note that This week is a default kibana quick range.

So yesterday is:

```
{
   "from": "now/d-1d",
   "to": "now/d-1d",
   "display": "Yesterday (Custom)",
   "section": 1
 }

```

By the way I found not easy to learn and understand quick ranges from the documentation (I'm the author of one of the othere post you mentioned) so I hope that the documentation will be improved.  
This filters are very, very important for anyone who works with data (and not just for logging).

---

<div class="post-metadata">

**Author:** ![edwardj3](https://avatars.discourse-cdn.com/v4/letter/e/d2c977/32.png) [@edwardj3](https://discuss.elastic.co/u/edwardj3)\
**Post date:** [April 5, 2020, 7:39pm UTC](https://discuss.elastic.co/t/custom-date-range-selectors/226567/3 "2020-04-05T19:39:24Z")

</div>

Thank you @mattiacareddu. Totally agree - they are important and I'm a little surprised they are not available as standard. I will pass these on so they can be created in our environments.

---

<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:** [May 3, 2020, 7:39pm UTC](https://discuss.elastic.co/t/custom-date-range-selectors/226567/4 "2020-05-03T19:39:24Z")

</div>

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