# Reindexing string to date format error

**URL:** <https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526>\
**Category:** Elasticsearch\
**Created:** [June 1, 2016, 8:35am UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526 "2016-06-01T08:35:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Uros\_Meglic](https://avatars.discourse-cdn.com/v4/letter/u/edb3f5/32.png) [@Uros\_Meglic](https://discuss.elastic.co/u/Uros_Meglic)\
**Post date:** [June 1, 2016, 8:35am UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526/1 "2016-06-01T08:35:52Z")

</div>

Hello,

I'm trying to reindex my data because of mapping changes and in this process I´m trying to convert a string to date format. The string of the date looks like this : "01.06.2016 01:05:34".

My template for this field:

```
"DispatchTime" : {
            "type" : "date",
            "format" : "dd.MM.yyyy HH:mm:ss"

```

But when I run the reindex api I get `"Invalid format: \"31.05.2016 11:01:46\" is malformed at \".05.2016 11:01:46\"`

What am I doing wrong? I'm a kind of new to elastic and maybe my whole logic of tackling this re-indexing is wrong.

Thanks and kind regards,

Uros

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [June 1, 2016, 10:08am UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526/2 "2016-06-01T10:08:46Z")

</div>

> [@Uros\_Meglic](#):
>
> "dd.MM.yyyy HH:mm:ss"

This looks correct for a date like `31.05.2016 11:01:46` so I guess the template was not correctly applies to the index you are reindexing to. What does "\_mapping" for the target index tell you, did it pick up the correct format string?

---

<div class="post-metadata">

**Author:** ![Uros\_Meglic](https://avatars.discourse-cdn.com/v4/letter/u/edb3f5/32.png) [@Uros\_Meglic](https://discuss.elastic.co/u/Uros_Meglic)\
**Post date:** [June 1, 2016, 11:06am UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526/3 "2016-06-01T11:06:46Z")

</div>

Hello,

the \_mapping shows:

```
"DispatchTime" : {
            "type" : "date",
            "format" : "strict_date_optional_time||epoch_millis"

```

It looks like it didn't pick up the correct settings I guess.

---

<div class="post-metadata">

**Author:** ![Uros\_Meglic](https://avatars.discourse-cdn.com/v4/letter/u/edb3f5/32.png) [@Uros\_Meglic](https://discuss.elastic.co/u/Uros_Meglic)\
**Post date:** [June 1, 2016, 11:30am UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526/4 "2016-06-01T11:30:29Z")

</div>

I found the problem. Deleted the new index and reran the reindex and it is ok. I first applied the wrong template, but forgot to clean the new index,

It's working now, thanks.

Kind regards,

Uros

---

<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:47pm UTC](https://discuss.elastic.co/t/reindexing-string-to-date-format-error/51526/5 "2017-07-05T22:47:18Z")

</div>


