# Date\_histogram with date range date type is text

**URL:** https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501
**Category:** Elasticsearch
**Created:** [July 15, 2019, 10:31am UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501 "2019-07-15T10:31:47Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![nitingarg](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nitingarg](https://discuss.elastic.co/u/nitingarg)
#### Post date: [July 15, 2019, 10:31am UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/1 "2019-07-15T10:31:47Z")

</div>

{  
"query": {  
"range": {  
"created\_ts": {  
"from": "2018-03-28",  
"to": "2019-07-28"  
}  
}  
},  
"aggs": {  
"group\_by\_created\_ts": {  
"date\_histogram": {  
"field": "created\_ts",  
"interval": "day",  
"format": "yyyy-MM-dd"  
}  
}  
}  
}

---

<div class="post-metadata">

### Author: ![nitingarg](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nitingarg](https://discuss.elastic.co/u/nitingarg)
#### Post date: [July 15, 2019, 10:32am UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/2 "2019-07-15T10:32:23Z")

</div>

getting error  
"reason": {  
"type": "illegal\_argument\_exception",  
"reason": "Field [created\_ts] of type [text] does not support custom formats"  
}

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 15, 2019, 11:53am UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/3 "2019-07-15T11:53:20Z")

</div>

Change your mapping and make that field a `date` field.

---

<div class="post-metadata">

### Author: ![nitingarg](https://avatars.discourse-cdn.com/v4/letter/n/53a042/32.png) [@nitingarg](https://discuss.elastic.co/u/nitingarg)
#### Post date: [July 15, 2019, 1:34pm UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/4 "2019-07-15T13:34:55Z")

</div>

ok, Then without drooping index , can change text to date?

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [July 15, 2019, 1:50pm UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/5 "2019-07-15T13:50:27Z")

</div>

No. You need to reindex.

---

<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 12, 2019, 1:50pm UTC](https://discuss.elastic.co/t/date-histogram-with-date-range-date-type-is-text/190501/6 "2019-08-12T13:50:28Z")

</div>

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