How can I convert integer in hh:mm:ss

For some days I’ve tried to set up a chart in Grafana, but I have duration field in Integer, but I’d like to convert to hh:mm:ss, because the formats proposed by Grafana is not good to visualization.

I have this query in SQL that works well:

SELECT
ACP_Version AS [Version],
SUM(Duration) AS TotalDuration,
– Converte TotalDuration de segundos para hh:mm:ss
RIGHT(‘0’ + CAST(SUM(Duration) / 3600 AS VARCHAR), 2) + ‘:’ +
RIGHT(‘0’ + CAST((SUM(Duration) % 3600) / 60 AS VARCHAR), 2) + ‘:’ +
RIGHT(‘0’ + CAST(SUM(Duration) % 60 AS VARCHAR), 2) AS DurationFormatted
FROM
PERF_BUNDLE.dbo.Perf_BatchInformation
WHERE
BatchDescr LIKE ‘%PERF_EOM%’
GROUP BY
ACP_Version
ORDER BY
ACP_Version;

The problem is in chart I could display correcty, because it’s just displayed integer instead of showing my conversion. Does someone how to overcome this configuration?

welcome @robsonllaurindo

Which column has this hh:mm:ss data and what data type is it? please post some sample data as inline csv here like following

ACP_Version,Duration
2.5,2024-06-27 13:33:33

DurationFormatted is as hh:mm:ss converted by SQL. My column in the table is interger. This was closer that I could reach.

that is an implementation which that didn’t answer the question that was asked. what does your data look like and what do you want it to look like, just the data not the visualization?

I wanna visualize in the x axis ACP_Version and in the top of bar the duration in hh:mm:ss.
2024-08-01 19_53_03-Test Results_EndOfMonth_Bundle_2023_v5.xlsx - Excel

Thanks, but I solved it.

1 Like