# 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:** 5

<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:22am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/82 "2019-08-09T10:22:34Z")

</div>

Date,MobileNo,Msg,ServiceId,SMS,wsResponse,AKNMsgId,MMMsgId,AmountCharged  
4/30/2019 23:54,923459797512,NEWS,4080,"Moaziz Sarif, Ap ko News bundle k liye subscribe kia ja chuka hai @Rs13.15 incl of tax/month. Agar ap is service ko unsubscribe karna chahty hain tu _345_3461# dial kijye.",1,15941612,0,11

This is one record for testing

---

<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:25am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/83 "2019-08-09T10:25:14Z")

</div>

789 create the date format 789 is the index i created on run time can we do this that we create index and then load the data with the same index can the data parse into the same index ??

---

<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:26am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/84 "2019-08-09T10:26:49Z")

</div>

What should i do then to convert the date format string into data type data you have my config file in the above post and now you have 1 record for testing can you check on your elastic and share the output for me. Really appreciate it !!

---

<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:28am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/85 "2019-08-09T10:28:09Z")

</div>

can we have a session through any desk or team viewer ??

---

<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:34am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/86 "2019-08-09T10:34:51Z")

</div>

output of rubydebug

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/e/7/e7bed960c6f1d1af2eff38f0b00b4ff5510b6024.png)

---

<div class="post-metadata">

**Author:** ![admlko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/admlko/32/21787_2.png) [@admlko](https://discuss.elastic.co/u/admlko)\
**Post date:** [August 9, 2019, 10:41am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/87 "2019-08-09T10:41:38Z")

</div>

At least for the date parse failure, the format in your screenshot is: M/dd/yyyy HH:mm  
So:

```
date {
  match => ["Date", "M/dd/yyyy HH:mm"]
  target => "Date"
}

```

See: [https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html#plugins-filters-date-match)

---

<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:43am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/88 "2019-08-09T10:43:22Z")

</div>

the last screenshot i uploaded i use this date format  
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 9, 2019, 10:43am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/89 "2019-08-09T10:43:46Z")

</div>

ok i will try this format also

---

<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:47am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/90 "2019-08-09T10:47:36Z")

</div>

Thank a tons it woks date is converted in date format !! 🙂

---

<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:48am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/91 "2019-08-09T10:48:16Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/6/86533e699fbbde576227467c687d3b2e277a3197.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 9, 2019, 10:49am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/92 "2019-08-09T10:49:13Z")

</div>

Thank you everyone for helping me out specially thanks to @dgonzalezp

---

<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, 11:02am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/93 "2019-08-09T11:02:47Z")

</div>

Finally its solved! I was close, the problem was the format in the match section, thank you to @admlko for that  
was a pleasure @Syed.Ubaid 🙂

---

<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, 11:04am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/94 "2019-08-09T11:04:22Z")

</div>

@admlko@dgonzalezp if there is another config file i should check the date format in which format date is coming then write the same pattern in my config  
??

---

<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, 11:08am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/95 "2019-08-09T11:08:36Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/7/1/71f7839a34dbb8e8a40ce7888115e8f3dde9f651.png) if you see the screenshot the the message column start with date format which is mention by @admlko while in the date column date is scoming in YYYY:MM:DD .  
So if there is another config file i should check the date format and then write config file according to it

---

<div class="post-metadata">

**Author:** ![admlko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/admlko/32/21787_2.png) [@admlko](https://discuss.elastic.co/u/admlko)\
**Post date:** [August 9, 2019, 1:10pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/96 "2019-08-09T13:10:00Z")

</div>

If the date format varies between events, you can define multiple formats. The format in the screenshot is ISO8601, so:

`match => ["Date", "M/dd/yyyy HH:mm", “ISO8601”]`

Should work for these two formats.

EDIT: although I don’t see where the Date field comes in that event. The message field has the same format.

---

<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 16, 2019, 5:34pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/97 "2019-08-16T17:34:28Z")

</div>

2019-05-13 00:00:06.687

what to do for this format

---

<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 16, 2019, 5:41pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/98 "2019-08-16T17:41:56Z")

</div>

and also for this format 4/30/2019 1:35:16

---

<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 16, 2019, 5:42pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/99 "2019-08-16T17:42:57Z")

</div>

for this format 4/30/2019 1:35:16  
i use  
date {  
match =\> ["Date", "M/dd/yyyy HH:mm:ss"]  
target =\> "Date"  
}  
but it still remain in the string datatype

---

<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 16, 2019, 5:47pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/100 "2019-08-16T17:47:14Z")

</div>

@admlko please help

---

<div class="post-metadata">

**Author:** ![admlko](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/admlko/32/21787_2.png) [@admlko](https://discuss.elastic.co/u/admlko)\
**Post date:** [August 17, 2019, 4:41am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/193913/101 "2019-08-17T04:41:02Z")

</div>

> 2019-05-13 00:00:06.687

yyyy-MM-dd HH:mm:ss.SSS

> 4/30/2019 1:35:16

M/dd/yyyy H:mm:ss

I have already provided you with a link to the documentation where this is clearly explained.

> @admlko please help

Next time someone pings me, I expect that they want to buy consultation from me. If that is the case, you are very welcome.  
If not, I do this for fun on my free time. If I have some, I will drop by here (and also on other forums) and help others and learn. But please do not expect that this would be my job 🙂

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

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