# How to convert Date to specific format and string to amount conversion

**URL:** <https://discuss.elastic.co/t/how-to-convert-date-to-specific-format-and-string-to-amount-conversion/300591>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [March 24, 2022, 3:10pm UTC](https://discuss.elastic.co/t/how-to-convert-date-to-specific-format-and-string-to-amount-conversion/300591 "2022-03-24T15:10:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![slj](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@slj](https://discuss.elastic.co/u/slj)\
**Post date:** [March 24, 2022, 3:10pm UTC](https://discuss.elastic.co/t/how-to-convert-date-to-specific-format-and-string-to-amount-conversion/300591/1 "2022-03-24T15:10:46Z")

</div>

I am trying to create a aggregation query to filter data if 2 columns in same index is matching. My InputDate is '2022-03-02T03:33:34.000Z' format and exeDate in '2022-03-02'. if both dates are same then need to sum up the amount of those entries. I tried below query. I am facing issue in both date comparision

```auto
{
    "query": {
        "bool": {
            "must": [
                {
                    "script": {
                        "script": {
                             "source": "doc['exeDate'].value == doc['inputDate'].value",
                            "lang": "painless"
                        }
                    }
                } 
            ] ,
            "should": []
        }
    },
    "from": 0,
    "size": 10,
    "sort": [],
    "aggs": {
        "action": {
            "terms": {
                "field": "actionname.keyword"
            },
            "aggs": {
                "total": {
                    "value_count": {
                        "field": "actionStatus.keyword"
                    }
                },
                "amount": {
                    "sum": {
                        "script": {
                            "lang": "painless",
                            "source": "(params['status'].contains(doc['actionStatus.keyword'].value))? doc['amount'].value:0",
                            "params": {
                                "status": [
                                    "Completed"
                                ] 
                            }
                        }
                    }
                } 
            }
        }
    }
}

```

How do i modify this query to match only date, not with time

---

<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:** [April 21, 2022, 3:10pm UTC](https://discuss.elastic.co/t/how-to-convert-date-to-specific-format-and-string-to-amount-conversion/300591/2 "2022-04-21T15:10:53Z")

</div>

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