# Strange date behaviour when indexing content

**URL:** <https://discuss.elastic.co/t/strange-date-behaviour-when-indexing-content/49535>\
**Category:** Elasticsearch\
**Created:** [May 9, 2016, 10:03am UTC](https://discuss.elastic.co/t/strange-date-behaviour-when-indexing-content/49535 "2016-05-09T10:03:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vindoq](https://avatars.discourse-cdn.com/v4/letter/v/87869e/32.png) [@vindoq](https://discuss.elastic.co/u/vindoq)\
**Post date:** [May 9, 2016, 10:03am UTC](https://discuss.elastic.co/t/strange-date-behaviour-when-indexing-content/49535/1 "2016-05-09T10:03:04Z")

</div>

Hi.

I got a project where we insert bunch of data through spark streaming. Everything was fine until a colleague got a strange behaviour I never had.  
A date is mapped as "yyyy-MM-dd' 'HH:mm:ss", and only on his computer, some (about 1%) of the date, and randoms ones when we delete and replay the same datas, are inserted with the date of the insert instead of the real date.

I tried a lots of thing, like adding a duplicate of the fields, and it was fine.  
So, maybe it's because we made an alias, and the alias contains other index (we use index\_yy\_ww) which have older mapping (I first tried mapping date with "yyyy-MM-dd HH:mm:ss"). But that's weird, and I would like to know why it's happening.  
Or maybe I get the wrong format? the docs is not really well documented. If I read it correctly, I should use "yyyy'-'MM'-'dd' 'HH':'mm':'ss" but didn't find any example of this online, thus using the one I found most on stackoverflow ("yyyy-MM-dd' 'HH:mm:ss").

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![vindoq](https://avatars.discourse-cdn.com/v4/letter/v/87869e/32.png) [@vindoq](https://discuss.elastic.co/u/vindoq)\
**Post date:** [May 9, 2016, 1:38pm UTC](https://discuss.elastic.co/t/strange-date-behaviour-when-indexing-content/49535/2 "2016-05-09T13:38:05Z")

</div>

Well, doesn't seems linked to elasticsearch after some research.  
Seems like both format "yyyy'-'MM'-'dd' 'HH':'mm':'ss" and "yyyy-MM-dd' 'HH:mm:ss" are good.  
Which one should I use and why "yyyy-MM-dd HH:mm:ss" doesn't work?

---

<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 5, 2017, 10:52pm UTC](https://discuss.elastic.co/t/strange-date-behaviour-when-indexing-content/49535/3 "2017-07-05T22:52:59Z")

</div>


