# Custom dates with ElasticSearch mapping

**URL:** <https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752>\
**Category:** Elasticsearch\
**Created:** [May 17, 2012, 8:49pm UTC](https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752 "2012-05-17T20:49:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/allen_liu/32/2882_2.png) [@Allen\_Liu](https://discuss.elastic.co/u/Allen_Liu)\
**Post date:** [May 17, 2012, 8:49pm UTC](https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752/1 "2012-05-17T20:49:38Z")

</div>

I have a date field called "start\_date" with the following format:

August 2007  
July 2003  
January 1999

Would the mapping for this field be:

"completion\_date" : {  
"type" : "date",  
"format" : "yyyy M"  
}

Thanks!

Allen

---

<div class="post-metadata">

**Author:** ![Allen\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/allen_liu/32/2882_2.png) [@Allen\_Liu](https://discuss.elastic.co/u/Allen_Liu)\
**Post date:** [May 17, 2012, 8:50pm UTC](https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752/2 "2012-05-17T20:50:18Z")

</div>

Sorry, I meant to switch the month and year:

"completion\_date" : {  
"type" : "date",  
"format" : "M yyyy"  
}

On Thursday, May 17, 2012 1:49:38 PM UTC-7, Allen Liu wrote:

> I have a date field called "start\_date" with the following format:
> 
> August 2007  
> July 2003  
> January 1999
> 
> Would the mapping for this field be:
> 
> "completion\_date" : {  
> "type" : "date",  
> "format" : "yyyy M"  
> }
> 
> Thanks!
> 
> Allen

---

<div class="post-metadata">

**Author:** ![Allen\_Liu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/allen_liu/32/2882_2.png) [@Allen\_Liu](https://discuss.elastic.co/u/Allen_Liu)\
**Post date:** [May 17, 2012, 11:31pm UTC](https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752/3 "2012-05-17T23:31:53Z")

</div>

Ok..I figured it out:

"completion\_date" : {  
"type" : "date",  
"format" : "MMM yyyy"  
}

Supposedly 3 or more M's will bring it to text mode.

On Thursday, May 17, 2012 1:50:18 PM UTC-7, Allen Liu wrote:

> Sorry, I meant to switch the month and year:
> 
> "completion\_date" : {  
> "type" : "date",  
> "format" : "M yyyy"  
> }
> 
> On Thursday, May 17, 2012 1:49:38 PM UTC-7, Allen Liu wrote:
> 
> > I have a date field called "start\_date" with the following format:
> > 
> > August 2007  
> > July 2003  
> > January 1999
> > 
> > Would the mapping for this field be:
> > 
> > "completion\_date" : {  
> > "type" : "date",  
> > "format" : "yyyy M"  
> > }
> > 
> > Thanks!
> > 
> > Allen

---

<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:28am UTC](https://discuss.elastic.co/t/custom-dates-with-elasticsearch-mapping/7752/4 "2017-07-06T03:28:16Z")

</div>


