Keychain expressions - integer cast to string with formatting

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.

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:

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)@

1 Like