# Keychain expressions - integer cast to string with formatting

**URL:** <https://forum.inductiveautomation.com/t/keychain-expressions-integer-cast-to-string-with-formatting/77863>\
**Category:** Ignition\
**Created:** [August 15, 2023, 1:24pm UTC](https://forum.inductiveautomation.com/t/keychain-expressions-integer-cast-to-string-with-formatting/77863 "2023-08-15T13:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew.Meronek](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Andrew.Meronek](https://forum.inductiveautomation.com/u/Andrew.Meronek)\
**Post date:** [August 15, 2023, 1:24pm UTC](https://forum.inductiveautomation.com/t/keychain-expressions-integer-cast-to-string-with-formatting/77863/1 "2023-08-15T13:24:38Z")

</div>

This is pertaining to displaying data in Report builder tables.

I don't see the specific function listed in the keychain expressions documentation. I'm trying to do some visual prettification on a duration (given in seconds) that returns a string like h:mm:ss as hours, minutes, seconds. This works:

`@floor(time_running / 3600)@:@floor(time_running / 60) % 60@:@ceil(time_running % 60)@`

But if I want to force leading zeros in the minutes portion of the text string (only if the values are 0-9), I'd need to be able to do something like this:

`@floor(time_running / 3600)@:@String.format("%02d",(floor(time_running / 60) % 60))@:@ceil(time_running % 60)@`

which doesn't seem to work. I think that I'd rather try to do this in the report table object itself and not the underlying dataset, which comes from SQL queries.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 15, 2023, 3:14pm UTC](https://forum.inductiveautomation.com/t/keychain-expressions-integer-cast-to-string-with-formatting/77863/2 "2023-08-15T15:14:51Z")

</div>

Possibly something like this?  
`@floor(time_running / 3600)@:@floor(time_running / 60) % 60).format("00")@:@ceil(time_running % 60)@`

Per Reportmill's own documentation, at the top of the last page:

> **[keychains.pdf](https://www.reportmill.com/support/keychains.pdf)**
>
> 73.27 KB

---

<div class="post-metadata">

**Author:** ![Andrew.Meronek](https://avatars.discourse-cdn.com/v4/letter/a/a9a28c/32.png) [@Andrew.Meronek](https://forum.inductiveautomation.com/u/Andrew.Meronek)\
**Post date:** [August 16, 2023, 1:18pm UTC](https://forum.inductiveautomation.com/t/keychain-expressions-integer-cast-to-string-with-formatting/77863/3 "2023-08-16T13:18:15Z")

</div>

Ugh, that was hard. PGriffith, you're close but this worked:

@floor(time\_running / 3600)@:@(floor(time\_running / 60) % 60).format("00")@:@ceil(time\_running % 60)@
