I want to change the metric format from float to HH:MM:SS in Datastudio (or SQL).
For Example:
Float | HH:MM:SS |
---|---|
75 | 00:01:15 |
90 | 00:01:30 |
79.5 | 00:01:20 |
etc........
If your input seconds fit into 24 hours - so can be presented as a time type - use below
select format_timestamp('%T', timestamp_seconds(cast(seconds as int64))) time
if applied to sample data in your question - output is
In case if input seconds exceed 24 hours - you can use below - which gives you a string representation in format of H*:MM:SS
select format('%i:%s',
div(cast(seconds as int64), 3600),
format_timestamp('%M:%S', timestamp_seconds(mod(cast(seconds as int64), 3600)))
) time
with output as