# Convert Date String Into Date Format

**URL:** https://discuss.elastic.co/t/convert-date-string-into-date-format/250153
**Category:** Logstash
**Created:** [September 28, 2020, 9:26am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/250153 "2020-09-28T09:26:57Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![wahzix](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@wahzix](https://discuss.elastic.co/u/wahzix)
#### Post date: [September 28, 2020, 9:26am UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/250153/1 "2020-09-28T09:26:57Z")

</div>

Hi,

I want to convert a date which is like this :  
2020-09-18 15:42:41.5721

To do so, I have tried to use date plugin but it seems that it doesn't work. I have this \_dateparsefailure and my @timestamp hasn't changed

```auto
    date {
		match => ["time_stamp", "yyyy-MM-dd HH:mm:ss.SSS"]
	}

```

I've also tried to match with "ISO8601" as I read time\_stamp like this :  
%{TIMESTAMP\_ISO8601:time\_stamp}.  
Of course I've checked and it contains 2020-09-18 15:42:41.5721.

Can anyone help me ?

Thanks

---

<div class="post-metadata">

### Author: ![wahzix](https://avatars.discourse-cdn.com/v4/letter/w/439d5e/32.png) [@wahzix](https://discuss.elastic.co/u/wahzix)
#### Post date: [September 28, 2020, 12:12pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/250153/2 "2020-09-28T12:12:01Z")

</div>

I found a solution :  
I deleted the date filter and y added this to my mutate filter :

```
        gsub => [
                  "timestmp", " ", "T"
                ]

```

It's automatically converted as date type then

---

<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: [September 28, 2020, 12:40pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/250153/3 "2020-09-28T12:40:59Z")

</div>

> [@wahzix](#):
>
> `match => ["time_stamp", "yyyy-MM-dd HH:mm:ss.SSS"]`

The reason that does not work is because you have 4 digits sub-second. It would work if you used

```
match => ["time_stamp", "yyyy-MM-dd HH:mm:ss.SSSS"]

```

---

<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: [October 26, 2020, 12:41pm UTC](https://discuss.elastic.co/t/convert-date-string-into-date-format/250153/4 "2020-10-26T12:41:02Z")

</div>

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