# Elastic search

**URL:** <https://discuss.elastic.co/t/elastic-search/381550>\
**Category:** Kibana\
**Tags:** elastic-stack-monitoring\
**Created:** [September 3, 2025, 6:55am UTC](https://discuss.elastic.co/t/elastic-search/381550 "2025-09-03T06:55:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mayur\_khairnar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayur_khairnar/32/144866_2.png) [@mayur\_khairnar](https://discuss.elastic.co/u/mayur_khairnar)\
**Post date:** [September 3, 2025, 6:55am UTC](https://discuss.elastic.co/t/elastic-search/381550/1 "2025-09-03T06:55:23Z")

</div>

i am trying to create visualization of type data table , i want format one of column which shows date in this format Aug 22 10:05:00 2026 GMT , which is string type . i want to format column with condition “if expiry date is less than 7 days, mark as RED. if expiry is less than 30 days and greater than or equal to 7 days , mark as AMBER.“  
but problem is field on which i want add condition is string format , which is not supported in formula script ,

and if i try to do using data views from stack management then changes are impacting on complete index

plese suggest solution on this

---

<div class="post-metadata">

**Author:** ![Tortoise](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tortoise/32/147587_2.png) [@Tortoise](https://discuss.elastic.co/u/Tortoise)\
**Post date:** [September 4, 2025, 3:49am UTC](https://discuss.elastic.co/t/elastic-search/381550/2 "2025-09-04T03:49:50Z")

</div>

Hello @mayur_khairnar

Welcome to the Community!!

If the date field is in String than you might need to use a runtime field and based on this field you can have both convert date from string to date format + have the status RED/AMBER/GREEN/EXPIRED as per your requirement.

What is the issue faced by you in below line is not clear :

> [@mayur\_khairnar](#):
>
> and if i try to do using data views from stack management then changes are impacting on complete index

Reference Runtime field Status Logic :

```auto
ZonedDateTime expiry = ZonedDateTime.parse(doc['expiry_date.keyword'].value, DateTimeFormatter.ofPattern('MMM dd HH:mm:ss yyyy z', Locale.ENGLISH));
        long millisUntilExpiry = expiry.toInstant().toEpochMilli() - new Date().getTime();

        if (millisUntilExpiry < 0) {
          emit("EXPIRED");
        } else if (millisUntilExpiry < 604800000) {
          emit("RED");
        } else if (millisUntilExpiry < 2592000000L) {
          emit("AMBER");
        } else {
          emit("GREEN");
        }

```

You can set the format of the field & set the color at time of creation.

Thanks!!
