# Changing field format into proper date format that has date as TEXT

**URL:** https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736
**Category:** Elasticsearch
**Created:** [July 29, 2019, 3:21pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736 "2019-07-29T15:21:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![zatom](https://avatars.discourse-cdn.com/v4/letter/z/f0a364/32.png) [@zatom](https://discuss.elastic.co/u/zatom)
#### Post date: [July 29, 2019, 3:21pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/1 "2019-07-29T15:21:33Z")

</div>

hi, I currently have a field that is in this text format ( some field has "2019/03/25 00:00:00.000" and some docs in same field has "20190619"). I changed the mapping for the field as DATE (yyyy/MM/dd HH:mm:ss.SSSZZ), but the reindexing stops in halfway. It says some of the date length is small or something. Help me out here. what should be my correct mapping for this date?

---

<div class="post-metadata">

### Author: ![John\_Guzman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_guzman/32/83587_2.png) [@John\_Guzman](https://discuss.elastic.co/u/John_Guzman)
#### Post date: [July 29, 2019, 5:35pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/2 "2019-07-29T17:35:22Z")

</div>

Can you please let me see the error? Have you considered using a pipeline to transform the date field?

---

<div class="post-metadata">

### Author: ![zatom](https://avatars.discourse-cdn.com/v4/letter/z/f0a364/32.png) [@zatom](https://discuss.elastic.co/u/zatom)
#### Post date: [July 29, 2019, 5:50pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/3 "2019-07-29T17:50:26Z")

</div>

I didnot saved the error unfortunately. But, I tried different approach. since some of my docs were in yyyyMMdd, I created mapping like this while indexing and it worked. It reindexed everything. Now, I can do aggregation on the dates also. But, now I want to know how to change those yyyyMMdd format into the regular format yyyy/MM/dd. Any idea?:  
"field" : {  
"type" : "date",  
"format" : "yyyy/MM/dd HH:mm:ss.SSSZZ||yyyy/MM/dd HH:mm:ss.SSS||yyyy/MM/dd||yyyyMMdd"

---

<div class="post-metadata">

### Author: ![John\_Guzman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_guzman/32/83587_2.png) [@John\_Guzman](https://discuss.elastic.co/u/John_Guzman)
#### Post date: [July 29, 2019, 5:57pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/4 "2019-07-29T17:57:33Z")

</div>

If you are using Kibana, you can change the format of the displayed data in advanced settings. But if not, you cannot change the format defined in the mapping once created.

---

<div class="post-metadata">

### Author: ![John\_Guzman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john_guzman/32/83587_2.png) [@John\_Guzman](https://discuss.elastic.co/u/John_Guzman)
#### Post date: [July 29, 2019, 6:04pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/5 "2019-07-29T18:04:20Z")

</div>

What you should do is to manage to recieve and recognize any date format when indexing, then in your mapping define just the format you want to see in your index. As you are reindexing i recomend you using pipelines to recognize those date formats Elasticsearch is not seeing. And if you can index the data again like using logstash, use filters to show to elasticsearch those fields that are dates.

---

<div class="post-metadata">

### Author: ![zatom](https://avatars.discourse-cdn.com/v4/letter/z/f0a364/32.png) [@zatom](https://discuss.elastic.co/u/zatom)
#### Post date: [July 29, 2019, 6:31pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/6 "2019-07-29T18:31:06Z")

</div>

I am using kibana to reindex. Are you saying with pipeline, i will be able to change certain date format from source to destination while reindexing?

---

<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: [August 26, 2019, 6:31pm UTC](https://discuss.elastic.co/t/changing-field-format-into-proper-date-format-that-has-date-as-text/192736/7 "2019-08-26T18:31:38Z")

</div>

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