Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to present a duration (in seconds) stored in a BIGINT in the format "hh:mm:ss"?

João Pedro Gomes Ramalho August 30, 2024

I've already tried modifying the query to fetch the data using SQLite with something like this:
printf('%02d:%02d:%02d', AVG(time_in_status) / 3600, (AVG(time_in_status) % 3600) / 60, AVG(time_in_status) % 60)

but without much success.

I'm using Atlassian Datalake/Analytics to try to display this duration.
Has anybody already went through this process? I'm open to suggestions :)

1 answer

1 accepted

0 votes
Answer accepted
Pears Whims
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 1, 2024

Hi @João Pedro Gomes Ramalho ,

Can You please try one of those approaches, and let me know if any of them work.

 

strftime

SQL lite can support a built-in function strftime:

SELECT
strftime('%H:%M:%S', AVG(time_in_status), 'unixepoch') AS formatted_duration
FROM your_table;

 

casting

Your original query may not be working exactly due to casting issues. Consider using explicit casting

SELECT
printf('%02d:%02d:%02d',
CAST(AVG(time_in_status) AS INTEGER) / 3600,
(CAST(AVG(time_in_status) AS INTEGER) % 3600) / 60,
CAST(AVG(time_in_status) AS INTEGER) % 60
) AS formatted_duration
FROM your_table;

 

In case of any issues, may You please provide a test value for the timestamp as well as the error message?

Thank You!

Pears.

 

Pears Whims
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 5, 2024

Hello, @João Pedro Gomes Ramalho .

May you please let me know if the solution help You to progress on Your case?

Best of luck,
Pears.

João Pedro Gomes Ramalho September 30, 2024

Hello, @Pears Whims 
The second approach results by creating a custom column and appying it.
Best regards,
João



 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events