# Convert Number (elapsed\_time) into Time (HH:MM:SS)

**URL:** <https://discuss.elastic.co/t/convert-number-elapsed-time-into-time-hhss/218551>\
**Category:** Logstash\
**Created:** [February 10, 2020, 9:32am UTC](https://discuss.elastic.co/t/convert-number-elapsed-time-into-time-hhss/218551 "2020-02-10T09:32:52Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![angelo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/angelo/32/61325_2.png) [@angelo](https://discuss.elastic.co/u/angelo)\
**Post date:** [March 13, 2020, 3:55pm UTC](https://discuss.elastic.co/t/convert-number-elapsed-time-into-time-hhss/218551/3 "2020-03-13T15:55:15Z")

</div>

In terms of Kibana and the error that you have in your screenshot, it's pointing out that you have some documents that have a missing value for `elapsed_time` and that you should do a check first. So with that and assuming that you want to allow hours to be larger than 24 (or else in a date/time format, that would increment the day field), here is an example:

```auto
if (doc['elapsed_time'].size()==0) {
    return ""
} else {
    long elapsed_time=(long)doc["elapsed_time"].value*1000;

    long secondsInMilli = 1000;
    long minutesInMilli = secondsInMilli * 60;
    long hoursInMilli = minutesInMilli * 60;
    long daysInMilli = hoursInMilli * 24;

    // long elapsedDays = elapsed_time / daysInMilli;
    // elapsed_time = elapsed_time % daysInMilli;/
	
    long elapsedHours = elapsed_time / hoursInMilli;
    elapsed_time = elapsed_time % hoursInMilli;

    long elapsedMinutes = elapsed_time / minutesInMilli;
    elapsed_time = elapsed_time % minutesInMilli;

    long elapsedSeconds = elapsed_time / secondsInMilli;

    String my_answer = String.format('%02d:%02d:%02d', new def[] {(int)elapsedHours, (int)elapsedMinutes, (int)elapsedSeconds});
    return my_answer;
}

```

I left `elapsedDays` as a comment just in case you did want to use it.

 ![elapsed_time_scipted_field](https://us1.discourse-cdn.com/elastic/original/3X/6/8/682a51fcff8247b0026f97e643dfb7e89eb78fb3.png)

---

_[View the full topic](https://discuss.elastic.co/t/convert-number-elapsed-time-into-time-hhss/218551)._
