# Is my date field being parsed as a text field?

**URL:** https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073
**Category:** Elasticsearch
**Created:** [July 30, 2018, 1:12am UTC](https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073 "2018-07-30T01:12:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Ormesome](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@Ormesome](https://discuss.elastic.co/u/Ormesome)
#### Post date: [July 30, 2018, 1:12am UTC](https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073/1 "2018-07-30T01:12:27Z")

</div>

I've pushed a lot of data into an index (I admit, poorly named) with a field that looks like this:  
`"creationdate": "2016-05-24 09:31:09.0600000"`

When I search for it as a date I get zero results:  
GET /documents/\_search  
{  
"query": {  
"range": {  
"creationdate": {  
"gte": "2016-05-01",  
"lte": "2016-05-30"  
}  
}  
}  
}

When I search for it as a text field it can be found:  
GET /documents/\_search  
{  
"query": {  
"multi\_match" : {  
"query" : "2015-05-24",  
"fields" : ["creationdate"]  
}  
}  
}

Is this because I forgot the T in the timestamp?

When I manage the index patterns it correctly identifies it as a date.  
When I attempt a visualisation I see this error:  
`Visualize: Fielddata is disabled on text fields by default. Set fielddata=true on [creationdate] in order to load fielddata in memory by uninverting the inverted index.`

What do I need to do to make the date range queries and visualisations work?

---

<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 30, 2018, 3:37am UTC](https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073/2 "2018-07-30T03:37:10Z")

</div>

Create the right mapping for this field.  
See [https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/date.html)

---

<div class="post-metadata">

### Author: ![Ormesome](https://avatars.discourse-cdn.com/v4/letter/o/ecc23a/32.png) [@Ormesome](https://discuss.elastic.co/u/Ormesome)
#### Post date: [July 30, 2018, 4:54am UTC](https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073/3 "2018-07-30T04:54:58Z")

</div>

I formatted the field in accordance with the first bullet point on the linked page (using a space character to separate the date and the time). Elastic automagically determines that it's a date, but the range based queries don't work.

In playing with my environment I've discovered that you must separate the date and the time with the letter T. The queries now work as expected.

What this doesn't tell me is whether the dot milliseconds is valid syntax, or whether I must use the letter Z.

---

<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 27, 2018, 4:55am UTC](https://discuss.elastic.co/t/is-my-date-field-being-parsed-as-a-text-field/142073/4 "2018-08-27T04:55:02Z")

</div>

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