# Indexing custom date format

**URL:** https://discuss.elastic.co/t/indexing-custom-date-format/15979
**Category:** Elasticsearch
**Created:** [February 23, 2014, 10:35pm UTC](https://discuss.elastic.co/t/indexing-custom-date-format/15979 "2014-02-23T22:35:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)
#### Post date: [February 23, 2014, 10:35pm UTC](https://discuss.elastic.co/t/indexing-custom-date-format/15979/1 "2014-02-23T22:35:36Z")

</div>

All the out-of-the-box date formats are available here:  
[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html)

But other than preprocessing a custom date format before indexing the data,  
is there anything I can do on the mapping side to allow ES to process a  
date like:

"2013-11-23 22:39:11" and not throw errors like it is malformed at "  
22:39:11" ?

Thanks!

- Pulkit

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/47177c44-0c2d-43d0-a838-189ae17ced32%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/47177c44-0c2d-43d0-a838-189ae17ced32%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![pulkitsinghal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pulkitsinghal/32/802_2.png) [@pulkitsinghal](https://discuss.elastic.co/u/pulkitsinghal)
#### Post date: [February 23, 2014, 10:37pm UTC](https://discuss.elastic.co/t/indexing-custom-date-format/15979/2 "2014-02-23T22:37:23Z")

</div>

My current mapping looks like:

'sale\_date': {  
'format': 'dateOptionalTime',  
'type': 'date'  
}

On Sunday, February 23, 2014 4:35:36 PM UTC-6, pulkitsinghal wrote:

> All the out-of-the-box date formats are available here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html)
> 
> But other than preprocessing a custom date format before indexing the  
> data, is there anything I can do on the mapping side to allow ES to process  
> a date like:
> 
> "2013-11-23 22:39:11" and not throw errors like it is malformed at "  
> 22:39:11" ?
> 
> Thanks!
> 
> - Pulkit

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/61bc3b33-061d-4c02-b5ab-9bfae65c5b05%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/61bc3b33-061d-4c02-b5ab-9bfae65c5b05%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 24, 2014, 3:15pm UTC](https://discuss.elastic.co/t/indexing-custom-date-format/15979/3 "2014-02-24T15:15:35Z")

</div>

Hey,

you have to change the mapping to accept your custom date time format. You  
can set it in your mapping using the format parameter like this

{"sales\_date": {"type" : "date", "format" : "yyyy-MM-dd ... AND THE REST  
HERE"}}

it uses the java SimpleDateFormat class for the defining the date format..

--Alex

On Sun, Feb 23, 2014 at 11:37 PM, pulkitsinghal [pulkitsinghal@gmail.com](mailto:pulkitsinghal@gmail.com)wrote:

> My current mapping looks like:
> 
> 'sale\_date': {  
> 'format': 'dateOptionalTime',  
> 'type': 'date'  
> }
> 
> On Sunday, February 23, 2014 4:35:36 PM UTC-6, pulkitsinghal wrote:
> 
> > All the out-of-the-box date formats are available here:  
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/mapping-date-format.html
> > 
> > But other than preprocessing a custom date format before indexing the  
> > data, is there anything I can do on the mapping side to allow ES to process  
> > a date like:
> > 
> > "2013-11-23 22:39:11" and not throw errors like it is malformed at "  
> > 22:39:11" ?
> > 
> > Thanks!
> > 
> > - Pulkit
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/61bc3b33-061d-4c02-b5ab-9bfae65c5b05%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/61bc3b33-061d-4c02-b5ab-9bfae65c5b05%40googlegroups.com)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-vavw8WD\_-6g8Fnf%2B6L1gUp3\_FLy0wk3VsyrJjJ4kaxQ%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM-vavw8WD_-6g8Fnf%2B6L1gUp3_FLy0wk3VsyrJjJ4kaxQ%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:47am UTC](https://discuss.elastic.co/t/indexing-custom-date-format/15979/4 "2017-07-06T01:47:45Z")

</div>


