# Logstash not formatting date to yyyyMMdd

**URL:** <https://discuss.elastic.co/t/logstash-not-formatting-date-to-yyyymmdd/218506>\
**Category:** Logstash\
**Created:** [February 10, 2020, 4:02am UTC](https://discuss.elastic.co/t/logstash-not-formatting-date-to-yyyymmdd/218506 "2020-02-10T04:02:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishna\_bhargav](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/krishna_bhargav/32/50877_2.png) [@krishna\_bhargav](https://discuss.elastic.co/u/krishna_bhargav)\
**Post date:** [February 10, 2020, 4:02am UTC](https://discuss.elastic.co/t/logstash-not-formatting-date-to-yyyymmdd/218506/1 "2020-02-10T04:02:31Z")

</div>

Here is the snippet, the date in load file comes as string as 2020-02-06-07.51.19.413216, we need to load it to elastic in format yyyyMMdd. But the below code only converts String to date and not the format.

filter {

```
	date {
		match => ["OPEN_DATE","yyyyMMdd"]
		target => "OPEN_DATE"		
	}
}
```

---

<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 10, 2020, 2:51pm UTC](https://discuss.elastic.co/t/logstash-not-formatting-date-to-yyyymmdd/218506/2 "2020-02-10T14:51:10Z")

</div>

The format in a date filter has to match the format of the date. Something like yyyy-MM-dd-HH-mm-ss-SSSSSS

You can then use a ruby filter and strftime to create a string in a different format.

---

<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 9, 2020, 2:51pm UTC](https://discuss.elastic.co/t/logstash-not-formatting-date-to-yyyymmdd/218506/3 "2020-03-09T14:51:16Z")

</div>

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