# Logstash Two Different Date Format

**URL:** <https://discuss.elastic.co/t/logstash-two-different-date-format/219718>\
**Category:** Logstash\
**Created:** [February 18, 2020, 6:47am UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718 "2020-02-18T06:47:46Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [February 18, 2020, 6:47am UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718/1 "2020-02-18T06:47:47Z")

</div>

I am parsing data from mysql to kibana. I have datefield which has datatype varchar  
now i have two different date format that is 1/4/2020 2:17:23 PM and 1/1/2020 12:00:00 AM  
can anyone please tell me what is the correct date format to parse both date and when data is parse the date datatype should be date.  
I am trying 1/1/2020 12:00:00 AM  
date {  
match =\> ["Date","M/d/yyyy H:mm:ss a"]  
target =\> "Date"

---

<div class="post-metadata">

**Author:** ![mikewillis](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikewillis](https://discuss.elastic.co/u/mikewillis)\
**Post date:** [February 18, 2020, 12:29pm UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718/2 "2020-02-18T12:29:23Z")

</div>

As described at [https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-date.html) you can specify multiple patterns to try matching against. For the examples you mention try this:

```
 match => ["Date","M/d/yyyy H:mm:ss a", "M/d/yyyy HH:mm:ss a"]

```

Note that neither of those patterns will match if the date or the month has more than one digit.

---

<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:** [February 18, 2020, 12:50pm UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718/3 "2020-02-18T12:50:16Z")

</div>

I have try this date format but date still is string not date datatype

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [February 18, 2020, 2:10pm UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718/4 "2020-02-18T14:10:00Z")

</div>

> [@mikewillis](#):
>
> Note that neither of those patterns will match if the date or the month has more than one digit.

This is not true.

```
input { generator { count => 1 lines => ['10/21/2020 12:00:00 AM'] } }
filter { date { match => ["message", "M/d/yyyy H:mm:ss a"] } }

```

parses that date just fine.

---

<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:** [March 17, 2020, 2:16pm UTC](https://discuss.elastic.co/t/logstash-two-different-date-format/219718/5 "2020-03-17T14:16:11Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
