# Date Format Issue

**URL:** <https://discuss.elastic.co/t/date-format-issue/7446>\
**Category:** Elasticsearch\
**Created:** [April 23, 2012, 10:07pm UTC](https://discuss.elastic.co/t/date-format-issue/7446 "2012-04-23T22:07:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![my3sons](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@my3sons](https://discuss.elastic.co/u/my3sons)\
**Post date:** [April 23, 2012, 10:07pm UTC](https://discuss.elastic.co/t/date-format-issue/7446/1 "2012-04-23T22:07:50Z")

</div>

Hello,

I have created the below mapping, and my issue is with the "submissionTime"  
field below. As you can see below, I have set the format to  
"yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the format  
described in the ES API docs. However, when I try and load this mapping, I  
get the below error:

{"error":"ElasticSearchException[Illegal pattern component: T]; nested:  
IllegalArgumentException[Illegal pattern component: T]; ","status":500}

Any ideas as to why it does not like the 'T' in the format?

curl -XPUT localhost:9200/reviews/test/\_mapping -d '{

"terms" : {  
"properties" : {  
"comment" : {  
"type" : "string",  
"index" : "analyzed",  
"includeInAll" : true  
},  
"rating" : {  
"type" : "double",  
"index" : "not\_analyzed",  
"includeInAll" : false  
},  
"title" : {  
"type" : "string",  
"index" : "not\_analyzed",  
"includeInAll" : false  
},  
"submissionTime" : {  
"type" : "date",  
"index" : "not\_analyzed",  
"includeInAll" : false,  
"format" : "yyyy-MM-dd'T'HH:mm:ss"  
},  
"sku" : {  
"type" : "integer",  
"index" : "analyzed",  
"includeInAll" : false  
},  
"id" : {  
"type" : "integer",  
"index" : "no",  
"includeInAll" : false  
},  
"reviewer": {  
"type": "object",  
"properties": {  
"name" : {"type" : "string", "index" : "not\_analyzed",  
"includeInAll" : false}  
}  
}

}  
}  
}  
}'

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [April 23, 2012, 10:34pm UTC](https://discuss.elastic.co/t/date-format-issue/7446/2 "2012-04-23T22:34:16Z")

</div>

You are using single quotes for the entire JSON and for T. As a result, T  
is sent without quotes. Try surrounding T with ''' like this:

"format" : "yyyy-MM-dd'''T'''HH:mm:ss"

On Monday, April 23, 2012 6:07:50 PM UTC-4, my3sons wrote:

> Hello,
> 
> I have created the below mapping, and my issue is with the  
> "submissionTime" field below. As you can see below, I have set the format  
> to "yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the  
> format described in the ES API docs. However, when I try and load this  
> mapping, I get the below error:
> 
> {"error":"ElasticSearchException[Illegal pattern component: T]; nested:  
> IllegalArgumentException[Illegal pattern component: T]; ","status":500}
> 
> Any ideas as to why it does not like the 'T' in the format?
> 
> curl -XPUT localhost:9200/reviews/test/\_mapping -d '{
> 
> "terms" : {  
> "properties" : {  
> "comment" : {  
> "type" : "string",  
> "index" : "analyzed",  
> "includeInAll" : true  
> },  
> "rating" : {  
> "type" : "double",  
> "index" : "not\_analyzed",  
> "includeInAll" : false  
> },  
> "title" : {  
> "type" : "string",  
> "index" : "not\_analyzed",  
> "includeInAll" : false  
> },  
> "submissionTime" : {  
> "type" : "date",  
> "index" : "not\_analyzed",  
> "includeInAll" : false,  
> "format" : "yyyy-MM-dd'T'HH:mm:ss"  
> },  
> "sku" : {  
> "type" : "integer",  
> "index" : "analyzed",  
> "includeInAll" : false  
> },  
> "id" : {  
> "type" : "integer",  
> "index" : "no",  
> "includeInAll" : false  
> },  
> "reviewer": {  
> "type": "object",  
> "properties": {  
> "name" : {"type" : "string", "index" : "not\_analyzed",  
> "includeInAll" : false}  
> }  
> }
> 
> }  
> }  
> }  
> }'

---

<div class="post-metadata">

**Author:** ![my3sons](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@my3sons](https://discuss.elastic.co/u/my3sons)\
**Post date:** [April 24, 2012, 2:24am UTC](https://discuss.elastic.co/t/date-format-issue/7446/3 "2012-04-24T02:24:52Z")

</div>

dohhh 🙂 Thanks Igor, that did the trick!

On Monday, April 23, 2012 5:34:16 PM UTC-5, Igor Motov wrote:

> You are using single quotes for the entire JSON and for T. As a result, T  
> is sent without quotes. Try surrounding T with ''' like this:
> 
> "format" : "yyyy-MM-dd'''T'''HH:mm:ss"
> 
> On Monday, April 23, 2012 6:07:50 PM UTC-4, my3sons wrote:
> 
> > Hello,
> > 
> > I have created the below mapping, and my issue is with the  
> > "submissionTime" field below. As you can see below, I have set the format  
> > to "yyyy-MM-dd'T'HH:mm:ss", which matches both my incoming data and the  
> > format described in the ES API docs. However, when I try and load this  
> > mapping, I get the below error:
> > 
> > {"error":"ElasticSearchException[Illegal pattern component: T]; nested:  
> > IllegalArgumentException[Illegal pattern component: T]; ","status":500}
> > 
> > Any ideas as to why it does not like the 'T' in the format?
> > 
> > curl -XPUT localhost:9200/reviews/test/\_mapping -d '{
> > 
> > "terms" : {  
> > "properties" : {  
> > "comment" : {  
> > "type" : "string",  
> > "index" : "analyzed",  
> > "includeInAll" : true  
> > },  
> > "rating" : {  
> > "type" : "double",  
> > "index" : "not\_analyzed",  
> > "includeInAll" : false  
> > },  
> > "title" : {  
> > "type" : "string",  
> > "index" : "not\_analyzed",  
> > "includeInAll" : false  
> > },  
> > "submissionTime" : {  
> > "type" : "date",  
> > "index" : "not\_analyzed",  
> > "includeInAll" : false,  
> > "format" : "yyyy-MM-dd'T'HH:mm:ss"  
> > },  
> > "sku" : {  
> > "type" : "integer",  
> > "index" : "analyzed",  
> > "includeInAll" : false  
> > },  
> > "id" : {  
> > "type" : "integer",  
> > "index" : "no",  
> > "includeInAll" : false  
> > },  
> > "reviewer": {  
> > "type": "object",  
> > "properties": {  
> > "name" : {"type" : "string", "index" : "not\_analyzed",  
> > "includeInAll" : false}  
> > }  
> > }
> > 
> > }  
> > }  
> > }  
> > }'

---

<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:** [July 6, 2017, 3:31am UTC](https://discuss.elastic.co/t/date-format-issue/7446/4 "2017-07-06T03:31:18Z")

</div>


