# How to convert format "yyyy-MM-dd HH:mm:ss in logstash?

**URL:** <https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005>\
**Category:** Logstash\
**Created:** [October 14, 2020, 7:59am UTC](https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005 "2020-10-14T07:59:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pamiers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pamiers/32/77142_2.png) [@pamiers](https://discuss.elastic.co/u/pamiers)\
**Post date:** [October 14, 2020, 7:59am UTC](https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005/1 "2020-10-14T07:59:18Z")

</div>

I fetch the data through Oracle, and the database has a field updated\_at in the format "yyyy-MM-dd HH:mm:ss". However, it has been automatically changed to ISO8601 format in logstash. So I try to change the format "yyyy-MM-dd HH:mm:ss", but I get an error like \_dateparsefailure. Here is my config file. What is the problem?

```auto
input {
   jdbc {
        jdbc_validate_connection => true
        jdbc_driver_library => "/usr/share/logstash/logstash-core/lib/jars/ojdbc8.jar"
        jdbc_driver_class => "Java::oracle.jdbc.OracleDriver"
        jdbc_connection_string => <connection string>
        jdbc_user => <my username>
        jdbc_password => <my password>
        use_column_value => true
        statement => "SELECT * FROM IP_INFO"
        schedule => "*/1 * * * *"
        charset => "UTF-8"
        enable_metric => false
   }

}

filter {
    date {
        match => [
            "updated_at", "yyyy-MM-dd HH:mm:ss"
        ]
        target => "updated_at"
    }
}

output {
  stdout {
    codec => rubydebug
  }
}

```

Result

```auto
{
    "@timestamp" => 2020-10-14T07:34:03.755Z,
    "updated_at" => 2020-10-14T04:44:37.000Z,
    "tags" => [
        [0] "_dateparsefailure"
    ],
    "created_at" => 2020-09-29T15:56:37.000Z
}

```

So, I just convert updated\_at and created\_at field to "yyyy-MM-dd HH:mm:ss". Can you help me?

---

<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:** [October 14, 2020, 2:45pm UTC](https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005/2 "2020-10-14T14:45:30Z")

</div>

> [@pamiers](#):
>
> `"updated_at" => 2020-10-14T04:44:37.000Z,`

Note that the field does not have quotes around it. It is not a string, it is converted to a Logstash::Timestamp object by the jdbc filter. A date filter only parses strings, it produces Logstash::Timestamp objects, it cannot parse them.

Since you want a timestamp in the end you can just delete the date filter. If you wanted to keep it as a string you could use mutate+convert to switch it back to a string. If you wanted a string with a different format you would use a ruby filter and strftime.

---

<div class="post-metadata">

**Author:** ![pamiers](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pamiers/32/77142_2.png) [@pamiers](https://discuss.elastic.co/u/pamiers)\
**Post date:** [October 15, 2020, 2:28am UTC](https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005/3 "2020-10-15T02:28:12Z")

</div>

thank you

---

<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:** [November 12, 2020, 2:28am UTC](https://discuss.elastic.co/t/how-to-convert-format-yyyy-mm-dd-hhss-in-logstash/252005/4 "2020-11-12T02:28:18Z")

</div>

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