# Convert string to date and change date format

**URL:** <https://discuss.elastic.co/t/convert-string-to-date-and-change-date-format/98333>\
**Category:** Logstash\
**Created:** [August 25, 2017, 6:43am UTC](https://discuss.elastic.co/t/convert-string-to-date-and-change-date-format/98333 "2017-08-25T06:43:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan](https://avatars.discourse-cdn.com/v4/letter/d/eada6e/32.png) [@Dan](https://discuss.elastic.co/u/Dan)\
**Post date:** [August 25, 2017, 6:43am UTC](https://discuss.elastic.co/t/convert-string-to-date-and-change-date-format/98333/1 "2017-08-25T06:43:12Z")

</div>

I am using JDBC input.

In my sql query craeteddate is a date field,When i am running logstash without any filter createddate field recognizing as date field.

But i don't want time in craeteddate,So applied ruby filter to convert my createddate format.After applying this filter createddate converted as string.

Example:  
Createddate from Database August 25th 2017, 12:03:02.653  
what i need : August 25th 2017

After this i applied date filter to convert createddate from string to date.

After this filter i am again getting time in createddate,But i dont want time in createddate.

Below are my filters

```
ruby {
        code => "event.set('createddate', event.get('[createddate]').time.strftime('%d-%m-%Y'))"
    }
date {
        match => ["createddate","dd-MM-yy"]
        target => "createddate"
   }

```

Please help me how can i get only date

---

<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:** [September 22, 2017, 6:43am UTC](https://discuss.elastic.co/t/convert-string-to-date-and-change-date-format/98333/2 "2017-09-22T06:43:31Z")

</div>

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