# Formation duration as HH:mm

**URL:** <https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054>\
**Category:** DQL\
**Tags:** dql, logs\
**Created:** [February 3, 2025, 1:27pm UTC](https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054 "2025-02-03T13:27:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jarren](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@Jarren](https://community.dynatrace.com/u/Jarren)\
**Post date:** [February 3, 2025, 1:27pm UTC](https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054/1 "2025-02-03T13:27:51Z")

</div>

I have a dashboard that lists task durations based on log timestamps. My DQL looks something like.

```auto
fetch logs
| parse content, "LD JSON:audit"
| fields timestamp, audit
| fieldsAdd uuid = audit[uuid], Task = audit[status_name], status = audit[status]
| fieldsRemove audit
| summarize {start_time = min (timestamp),
end_time = max(timestamp)}
, by: {uuid, Task}
| fieldsAdd runtime = end_time - start_time
| fields Task, runtime, start_time, end_time

```

The field runtime has the datatype “duration”, is listed in nanoseconds and is formatted as hours. So in the dashboard the durations are shows as “3,15 h” and “11,99 h”. However I want to format it as HH:mm. So “3,15 h” is “03:09” and “2,99 h” is “11:59”. How can I do this?

---

<div class="post-metadata">

**Author:** ![krzysztof\_hoja](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/krzysztof_hoja/32/34625_2.png) [@krzysztof\_hoja](https://community.dynatrace.com/u/krzysztof_hoja)\
**Post date:** [February 3, 2025, 7:29pm UTC](https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054/2 "2025-02-03T19:29:59Z")

</div>

Unfortunately there is not with single function call, but with some arithmetic and string operations:

```markup
data record(d=duration(3.15, "h")),
record(d=duration(2.99, "h")),
record(d=duration(1.8, "m")),
record(d=duration(120, "m")),
record(d=duration(12.25, "h")),
record(d=duration(5, "d")),
record(d=duration(30, "s")),
record(d=duration(29, "s")),
record(d=duration(10, "ms"))
| fieldsAdd h=toString(toLong(d/1h)), m=toString(toLong(round(d/1m)) % 60)
| fields d, hm = concat( if(stringLength(h)<2, concat("0",h), else:h), ":", if(stringLength(m)<2, concat("0",m), else:m))

```

 ![krzysztof_hoja_0-1738610976726.png](https://global.discourse-cdn.com/dynatrace/original/3X/e/b/eb2cbb73fdfb201ad9dcca5a427755d32550811c.png)

---

<div class="post-metadata">

**Author:** ![Jarren](https://avatars.discourse-cdn.com/v4/letter/j/45deac/32.png) [@Jarren](https://community.dynatrace.com/u/Jarren)\
**Post date:** [February 4, 2025, 6:45am UTC](https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054/3 "2025-02-04T06:45:46Z")

</div>

Thank you, it works!

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [August 7, 2025, 8:28pm UTC](https://community.dynatrace.com/t/formation-duration-as-hh-mm/50054/4 "2025-08-07T20:28:51Z")

</div>

Hi, can you please tell me how did u achieve this with the runtime field u have in the dql ? I have similar query, but not able to change the format in my dashboard.
