# Ruby time.strftime logstash

**URL:** <https://discuss.elastic.co/t/ruby-time-strftime-logstash/238138>\
**Category:** Logstash\
**Created:** [June 22, 2020, 6:37pm UTC](https://discuss.elastic.co/t/ruby-time-strftime-logstash/238138 "2020-06-22T18:37:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rushabh\_Doshi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rushabh_doshi/32/69886_2.png) [@Rushabh\_Doshi](https://discuss.elastic.co/u/Rushabh_Doshi)\
**Post date:** [June 22, 2020, 6:37pm UTC](https://discuss.elastic.co/t/ruby-time-strftime-logstash/238138/1 "2020-06-22T18:37:45Z")

</div>

Hi

I want to convert hour to number , hour is extracted from timestamp as below in logstash:

ruby { code =\> "event.set('[hour]',event.get('Activity-Time-New').time.strftime('%k') )" }

In Kibana i want #hour ,a number data type instead of string, in kibana i get it as a string

I tried mutate convert but its not working please guide how can i convert hour to number# in kibana

Regards

---

<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:** [June 22, 2020, 7:05pm UTC](https://discuss.elastic.co/t/ruby-time-strftime-logstash/238138/2 "2020-06-22T19:05:58Z")

</div>

You would use

```
mutate { convert => { "hour" => "integer" } }

```

However, if you have already indexed documents where [hour] was a string, then elasticsearch will convert the integer to a string as it indexes new documents. You will need to index the documents into a new index.

---

<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:** [July 20, 2020, 7:06pm UTC](https://discuss.elastic.co/t/ruby-time-strftime-logstash/238138/3 "2020-07-20T19:06:07Z")

</div>

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