# JSON Input: Converting Minutes to Minutes and Seconds

**URL:** <https://discuss.elastic.co/t/json-input-converting-minutes-to-minutes-and-seconds/100845>\
**Category:** Kibana\
**Created:** [September 18, 2017, 9:47am UTC](https://discuss.elastic.co/t/json-input-converting-minutes-to-minutes-and-seconds/100845 "2017-09-18T09:47:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mentari\_mrh](https://avatars.discourse-cdn.com/v4/letter/m/e19adc/32.png) [@mentari\_mrh](https://discuss.elastic.co/u/mentari_mrh)\
**Post date:** [September 18, 2017, 9:47am UTC](https://discuss.elastic.co/t/json-input-converting-minutes-to-minutes-and-seconds/100845/1 "2017-09-18T09:47:43Z")

</div>

Hi

I'm using Kibana 5.5.1

I want to convert serveAvg (currently in seconds) to Minutes and Seconds.  
Currently i managed to convert to Minutes only using below script

{  
"script": {  
"inline1": "doc['serveAvg'].value / 60",  
"lang": "painless"  
}

for example serveAve = 217.671

when convert using above script it gave me 3.628

i want the result to be 3 minutes and 38 seconds. Can anyone please help me to solve this prob. Tq

![image](https://us1.discourse-cdn.com/elastic/original/3X/8/a/8ad9e3a2d89ff8847da11d66c865a34af2a61a87.png)

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [September 18, 2017, 7:46pm UTC](https://discuss.elastic.co/t/json-input-converting-minutes-to-minutes-and-seconds/100845/2 "2017-09-18T19:46:18Z")

</div>

I think you could put this script in the JSON Input field, but I found it a little easier to create a Scripted Field on my index to do it. And then you can use the scripted field in many visualizations without having to replicate that JSON Input code.

In the screenshot below, I used some number type field `metricset.rtt` and used it in a scripted field of type `date`.  
I set the Format to Date, and the pattern to minutes:seconds `mm:ss`. I guess it assumed the value was milliseconds so I multiplied by 1000. I named my scripted field `metricset.time`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/2/72af3f87fd4fc1782732039831db1f2bc18f52ce.png)

Now in Discover I can add both the original metricset.rtt and my scripted field metricset.time so I can check that the calculation is working as expected.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/6/c/6cb2fcf955722833c43d800f8a290995d804a2f2.png)

You could easily change it to `HH:mm:ss` or create another scripted field with that formatting.

Regards,  
Lee

---

<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:** [October 16, 2017, 7:46pm UTC](https://discuss.elastic.co/t/json-input-converting-minutes-to-minutes-and-seconds/100845/3 "2017-10-16T19:46:55Z")

</div>

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