# How to display Due, Over Due and Not Due based on a date field in Saved Search

**URL:** https://discuss.elastic.co/t/how-to-display-due-over-due-and-not-due-based-on-a-date-field-in-saved-search/254648
**Category:** Kibana
**Tags:** painless
**Created:** [November 8, 2020, 1:59am UTC](https://discuss.elastic.co/t/how-to-display-due-over-due-and-not-due-based-on-a-date-field-in-saved-search/254648 "2020-11-08T01:59:35Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![bkmagnetron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkmagnetron/32/38343_2.png) [@bkmagnetron](https://discuss.elastic.co/u/bkmagnetron)
#### Post date: [November 8, 2020, 1:59am UTC](https://discuss.elastic.co/t/how-to-display-due-over-due-and-not-due-based-on-a-date-field-in-saved-search/254648/1 "2020-11-08T01:59:35Z")

</div>

For example I have a date field `delivery_datetime` in Index, I have to show the user for current day whether a particular parcel is Due today or Over Due or Not Due

I can't create a separate field and do reindex because it's based on current date and that changes every day, for instance if I have to calculate while indexing I have to reindex every day, and that's not feasible because I have a lot of data.

I may use update by query but my index is frequently updated via a Python script, thought we don't have ACID property here I we'll have version conflict.

For my knowledge I think my only option is to use Scripted Field.

If I have to write the logic in pseudocode:

```auto
Due - delivery_datetime.dateOnly == now.dateOnly
Over Due - delivery_datetime.dateOnly < now.dateOnly
Not Due - delivery_datetime.dateOnly > now.dateOnly

```

Thought I have a lot of data if I generate CSV I don't want scripted field to make major impact on cluster performance.

So I need some help to do this efficiently in scripted field, or if there were any completely different solution will also be greatly helpful.

Expecting help by providing painless script for Scripted Field.

---

<div class="post-metadata">

### Author: ![bkmagnetron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bkmagnetron/32/38343_2.png) [@bkmagnetron](https://discuss.elastic.co/u/bkmagnetron)
#### Post date: [November 9, 2020, 7:37am UTC](https://discuss.elastic.co/t/how-to-display-due-over-due-and-not-due-based-on-a-date-field-in-saved-search/254648/2 "2020-11-09T07:37:12Z")

</div>

Answered here now [https://stackoverflow.com/q/64734208/1464519](https://stackoverflow.com/q/64734208/1464519)

---

<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: [December 7, 2020, 7:37am UTC](https://discuss.elastic.co/t/how-to-display-due-over-due-and-not-due-based-on-a-date-field-in-saved-search/254648/3 "2020-12-07T07:37:19Z")

</div>

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