# Elasticsearch dynamic date field mapping

**URL:** <https://discuss.elastic.co/t/elasticsearch-dynamic-date-field-mapping/334436>\
**Category:** Elasticsearch\
**Created:** [May 26, 2023, 1:16pm UTC](https://discuss.elastic.co/t/elasticsearch-dynamic-date-field-mapping/334436 "2023-05-26T13:16:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![riani.oussama](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@riani.oussama](https://discuss.elastic.co/u/riani.oussama)\
**Post date:** [May 26, 2023, 1:16pm UTC](https://discuss.elastic.co/t/elasticsearch-dynamic-date-field-mapping/334436/1 "2023-05-26T13:16:45Z")

</div>

Hi,

I have a problem in handling dates in my indexes.  
My indexes were created automatically from my application.

In one index the field "CreationDate" is of type text (Tue May 23 10:55:12 CEST 2023), in another index the field "CreationDate" is of type long (1685020804142) the milliseconds-since-the-epoch.

I would like to know why the dynamic field mapping did not work on this field? Why has this field not passed the detection date?

```auto
PUT my-index-000001
{
  "mappings": {
    "date_detection": true
  }
}

```

This gives

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "resource_already_exists_exception",
        "reason" : "index [my-index-000001/1CxdUvsQRsGNuOQ4TvpgXQ] already exists",
        "index_uuid" : "1CxdUvsQRsGNuOQ4TvpgXQ",
        "index" : "my-index-000001"
      }
    ],
    "type" : "resource_already_exists_exception",
    "reason" : "index [my-index-000001/1CxdUvsQRsGNuOQ4TvpgXQ] already exists",
    "index_uuid" : "1CxdUvsQRsGNuOQ4TvpgXQ",
    "index" : "my-index-000001"
  },
  "status" : 400
}

```

Thank you.

---

<div class="post-metadata">

**Author:** ![riani.oussama](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@riani.oussama](https://discuss.elastic.co/u/riani.oussama)\
**Post date:** [May 26, 2023, 1:25pm UTC](https://discuss.elastic.co/t/elasticsearch-dynamic-date-field-mapping/334436/2 "2023-05-26T13:25:26Z")

</div>

And how do I transform the type of the field "CreationDate" into Date please ?

---

<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:** [June 23, 2023, 1:25pm UTC](https://discuss.elastic.co/t/elasticsearch-dynamic-date-field-mapping/334436/3 "2023-06-23T13:25:48Z")

</div>

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