# Convert seconds (float number) into a more legible datatype

**URL:** https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257
**Category:** Kibana
**Created:** [August 12, 2015, 1:10pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257 "2015-08-12T13:10:12Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![pjvv1](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@pjvv1](https://discuss.elastic.co/u/pjvv1)
#### Post date: [August 12, 2015, 1:10pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/1 "2015-08-12T13:10:12Z")

</div>

Dear friends,

We have an ELK to get information about the use of one of our software applications.

We have a field for session duration which represent the duration (time) of a session in seconds. That is not very human-readable so I would like to change or convert it to something like "hh hours mm minutes ss seconds"

Can you tell me the way to do that?

Thanks in advance.

Regards

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 13, 2015, 12:06am UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/2 "2015-08-13T00:06:08Z")

</div>

You _might_ be able to do this with a [scripted field](https://www.elastic.co/guide/en/kibana/current/managing-fields.html#create-scripted-field), but I think it'd be tough.

Field formatters would probably also be able to do this, but they don't do time based formatters yet.

---

<div class="post-metadata">

### Author: ![asafyigal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asafyigal/32/685_2.png) [@asafyigal](https://discuss.elastic.co/u/asafyigal)
#### Post date: [August 13, 2015, 6:03am UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/3 "2015-08-13T06:03:48Z")

</div>

The easiest way is to do this in logstash.

-- Asaf.

---

<div class="post-metadata">

### Author: ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)
#### Post date: [August 13, 2015, 6:07am UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/4 "2015-08-13T06:07:29Z")

</div>

Heh, yeah, a lot easier! 😃

---

<div class="post-metadata">

### Author: ![pjvv1](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@pjvv1](https://discuss.elastic.co/u/pjvv1)
#### Post date: [August 13, 2015, 9:13am UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/5 "2015-08-13T09:13:45Z")

</div>

Thank you all for your answer.

After reading them, I've changed my question to "how to do it in ElasticSearch?" 😉

I've been looking for information about ElasticSearch datatypes but I haven't found any datatype related to time but dates, I mean I don't know hot to convert a float into a time expression (hh MM ss)

Thanks again.

---

<div class="post-metadata">

### Author: ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)
#### Post date: [August 13, 2015, 4:49pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/6 "2015-08-13T16:49:16Z")

</div>

I think you have to map your date as a date data type in ES:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html)

Once you have that, you can use date formatters in K4:  
[https://www.elastic.co/guide/en/kibana/current/managing-fields.html#\_date\_field\_formatters](https://www.elastic.co/guide/en/kibana/current/managing-fields.html#_date_field_formatters)

---

<div class="post-metadata">

### Author: ![pjvv1](https://avatars.discourse-cdn.com/v4/letter/p/848f3c/32.png) [@pjvv1](https://discuss.elastic.co/u/pjvv1)
#### Post date: [August 13, 2015, 5:14pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/7 "2015-08-13T17:14:40Z")

</div>

Thank you. My problem is that the field is not a date, it's the number of  
seconds (it represents a session duration), so transforming the float  
(seconds) data type to a time expression is not direct.

If I specify that field is a date in ElasticSearch, it will understand it  
is a date represented in UTC float and that's not the case.

Am I right? or did not understand your answer?

Thanks again.

---

<div class="post-metadata">

### Author: ![tbragin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tbragin/32/45166_2.png) [@tbragin](https://discuss.elastic.co/u/tbragin)
#### Post date: [August 13, 2015, 8:49pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/8 "2015-08-13T20:49:26Z")

</div>

Oh, right - I misunderstood what you were trying to do ☹

Converting a float representing setting duration to a custom time display is not possible at the moment, but is a reasonable enhancement request. Would you mind filing an issue in Github, if it's important to you? [https://github.com/elastic/kibana/issues](https://github.com/elastic/kibana/issues)

---

<div class="post-metadata">

### Author: ![asafyigal](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/asafyigal/32/685_2.png) [@asafyigal](https://discuss.elastic.co/u/asafyigal)
#### Post date: [August 18, 2015, 7:36am UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/9 "2015-08-18T07:36:10Z")

</div>

@pjvv1 - In Kibana 4.1 you have the ability to formal a number field into date format - check out this formatting options for additional info- [https://adamwdraper.github.io/Numeral-js/](https://adamwdraper.github.io/Numeral-js/)

-- Asaf.

---

<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 6, 2017, 2:14pm UTC](https://discuss.elastic.co/t/convert-seconds-float-number-into-a-more-legible-datatype/27257/10 "2017-07-06T14:14:41Z")

</div>


