# Issue with Date Formatting in Transform Script on Elasticsearch 8.6.1

**URL:** https://discuss.elastic.co/t/issue-with-date-formatting-in-transform-script-on-elasticsearch-8-6-1/349463
**Category:** Elasticsearch
**Created:** [December 15, 2023, 2:49pm UTC](https://discuss.elastic.co/t/issue-with-date-formatting-in-transform-script-on-elasticsearch-8-6-1/349463 "2023-12-15T14:49:39Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Behnam.R](https://avatars.discourse-cdn.com/v4/letter/b/48db29/32.png) [@Behnam.R](https://discuss.elastic.co/u/Behnam.R)
#### Post date: [December 15, 2023, 2:49pm UTC](https://discuss.elastic.co/t/issue-with-date-formatting-in-transform-script-on-elasticsearch-8-6-1/349463/1 "2023-12-15T14:49:39Z")

</div>

Hello,

I'm encountering an issue with date formatting in a transform script on Elasticsearch 8.6.1 (licensed version). My goal is to pivot existing index and store the date as it is. However, the output in the transformed index appears in EpochMilli format, even though I am fetching the value from a Date field.

Here's the relevant part of my transform script:

```auto

"issueDate": {
        "min": {
          "script": {
            "source": "doc['type.keyword'].value == 'TA' ? doc['createDate'].value : null"
          }
        }
      }

```

so this is my createDate:  
`Dec 13, 2023 @ 15:58:40.179`

and this is the issueDate after transform:  
`1702479520179`

I have also tried the transform without `.value` but the issue still persists. My question now is how can I avoid getting the epochmilli value, or if there is not way to avoid it how can I add the conversion inside the transform script?

---

<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: [January 12, 2024, 2:49pm UTC](https://discuss.elastic.co/t/issue-with-date-formatting-in-transform-script-on-elasticsearch-8-6-1/349463/2 "2024-01-12T14:49:58Z")

</div>

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