# Convert Date String Into Date Format

**URL:** <https://discuss.elastic.co/t/convert-date-string-into-date-format/193913>\
**Category:** Logstash\
**Created:** [August 6, 2019, 4:10am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913 "2019-08-06T04:10:30Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 11:53am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/62 "2019-08-08T11:53:05Z")

</div>

yes it works but if you see the screenshot i uploaded the date column still in string field

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 12:00pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/63 "2019-08-08T12:00:01Z")

</div>

if i see the mapping it show this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/3/8313943119697318b4f2998ac949081852035c5d.png)

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 12:11pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/64 "2019-08-08T12:11:55Z")

</div>

How to identify the template of current index ?? or should i create a template for the index if yes then how can i make a template with naming convention ?

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 8, 2019, 12:26pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/65 "2019-08-08T12:26:48Z")

</div>

Try this:

> filter {  
> csv {  
> separator =\> ","  
> columns =\> ["Date","MobileNo","Msg","ServiceId","SMS","wsResponse","AKNMsgId","MMMsgId","AmountCharged"]  
> }  
> date {  
> match =\> ["Date", "MM/DD/YYYY HH:mm"]  
> target =\> "Date"  
> }  
> mutate {convert =\> ["Date", "date"]}  
> }

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [August 8, 2019, 12:36pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/66 "2019-08-08T12:36:52Z")

</div>

If you have a look at the list of templates

`GET _cat/templates`

is there another one that might match your index name?

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 12:48pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/67 "2019-08-08T12:48:00Z")

</div>

filter {  
csv {  
separator =\> ","  
columns =\> ["Date","MobileNo","Msg","ServiceId","SMS","wsResponse","AKNMsgId","MMMsgId","AmountCharged"]  
}  
date {  
match =\> ["Date", "MM/DD/YYYY HH:mm"]  
target =\> "Date"  
}  
mutate {convert =\> ["Date", "date"]}  
}

Try this but it show error

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 12:49pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/68 "2019-08-08T12:49:45Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/b/a/ba9d59f9abeccc6a60edf7df3fb084275236a823.png) how i know which template using the current index pattern

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 8, 2019, 12:53pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/69 "2019-08-08T12:53:38Z")

</div>

Sorry my fault, that couldnt work, try with this one:

> filter {  
> csv {  
> separator =\> ","  
> columns =\> ["Date","MobileNo","Msg","ServiceId","SMS","wsResponse","AKNMsgId","MMMsgId","AmountCharged"]  
> }  
> date {  
> match =\> ["Date", "ISO8601", "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss.ZZZ"]  
> target =\> "Date"  
> locale =\> "en"  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 12:58pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/70 "2019-08-08T12:58:15Z")

</div>

Data is parse but result is still the same please check the attached screenshot i have created new index

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/1/018103e9731761e412a629d800ebc61fbe7c3e01.png)

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 1:01pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/71 "2019-08-08T13:01:44Z")

</div>

@dgonzalezp thank you for trying to solve the problem really appreciate it... but the problem still remains the same 🙂

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 8, 2019, 1:08pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/72 "2019-08-08T13:08:53Z")

</div>

Dont worry @Syed.Ubaid I want to help you 🙂 Lets keep trying with this now:

> filter {  
> if ([message] =~ "\bDate\b") {  
> drop { }  
> } else {  
> csv {  
> separator =\> ","  
> columns =\> ["Date","MobileNo","Msg","ServiceId","SMS","wsResponse","AKNMsgId","MMMsgId","AmountCharged"]  
> }  
> date {  
> match =\> ["Date", "ISO8601", "YYYY-MM-dd HH:mm:ss", "YYYY-MM-dd HH:mm:ss.ZZZ"]  
> target =\> "Date"  
> locale =\> "en"  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 8, 2019, 1:13pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/73 "2019-08-08T13:13:41Z")

</div>

still the problem remain same date field as string

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 9, 2019, 4:23am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/74 "2019-08-09T04:23:20Z")

</div>

any update @Jenni @dgonzalezp

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 9, 2019, 4:23am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/75 "2019-08-09T04:23:51Z")

</div>

@Jenni how would i know if my current index using any template ??

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 9, 2019, 6:01am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/76 "2019-08-09T06:01:04Z")

</div>

Good morning @Syed.Ubaid  
I need investigate a little bit more, give me time I will tell you when I find something

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 9, 2019, 6:03am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/77 "2019-08-09T06:03:38Z")

</div>

Morning 🙂 ok waiting

---

<div class="post-metadata">

**Author:** ![dgonzalezp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dgonzalezp/32/50804_2.png) [@dgonzalezp](https://discuss.elastic.co/u/dgonzalezp)\
**Post date:** [August 9, 2019, 8:12am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/78 "2019-08-09T08:12:52Z")

</div>

Sorry @Syed.Ubaid Im a little bit busy today but now I have time to help you,  
I want to test the same in my own Elastic so could you paste the content of one CSV file that you are using?

---

<div class="post-metadata">

**Author:** ![Jenni](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jenni/32/29684_2.png) [@Jenni](https://discuss.elastic.co/u/Jenni)\
**Post date:** [August 9, 2019, 8:17am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/79 "2019-08-09T08:17:47Z")

</div>

My thoughts on the topic:

1. I think your date conversion was right back when you were using

because that is the only pattern that matches your date string. Trying anything else doesn't make sense to me.  
2. If you used the debug output like I asked you to do, it would show us if we've got a Timestamp object or an error. But you didn't.  
3. Your earlier screenshot (the template list) shows '789' in the column for the matched index patterns of 'your\_template'. I don't know how that got there. But that would be the reason why it doesn't match your index name.  
4. Just to make sure that you are aware of that: Your first goal is to give Elasticsearch a field with a date datatype (which can accept multiple date formats, but we'd have to have working mapping for that telling ES which formats to accept). That probably won't be formatted like your original data by default in Kibana, so don't expect it to be. As soon as it is a date, we can change the formatting. But that is nothing more than a display setting in Kibana and doesn't change your data at all.

---

<div class="post-metadata">

**Author:** ![jmilot](https://avatars.discourse-cdn.com/v4/letter/j/77aa72/32.png) [@jmilot](https://discuss.elastic.co/u/jmilot)\
**Post date:** [August 9, 2019, 9:07am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/80 "2019-08-09T09:07:51Z")

</div>

Have you create a new index after add the template?

---

<div class="post-metadata">

**Author:** ![Syed.Ubaid](https://avatars.discourse-cdn.com/v4/letter/s/df705f/32.png) [@Syed.Ubaid](https://discuss.elastic.co/u/Syed.Ubaid)\
**Post date:** [August 9, 2019, 10:20am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/81 "2019-08-09T10:20:18Z")

</div>

Yes i created new inidex every time

[Previous page](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913.md?page=3)

[Next page](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913.md?page=5)
