Reputation: 11
I want to convert numbers (that represent seconds) into HH:MM:SS format (like shown in pic..) but don't want to split them.. I want to format it using some formula or
Upvotes: 0
Views: 154
Reputation: 60389
If you just want to display the 715 seconds as hours:minutes:seconds, you will need a helper column that you use just for display.
You can create it either as in your example screenshot, or using a formula:
=TEXT(B2/86400,"[hh]:mm:ss")
Note the brackets around hh
. That keeps the hours from rolling over every 24 and displays total hours correctly for instances where seconds > 86,400.
There's no way I know of to have 715 displayed as the associated hours:minutes:seconds in the same cell.
Upvotes: 1
Reputation: 37119
You can use a formula like this to convert 715 to HH:MM:SS:
=TEXT(FLOOR((A1-FLOOR(A1/86400,1)*86400)/3600, 1), "00:") & text(floor((A1 - floor(A1/3600,1)*3600)/60, 1),"00:") & text(A1 - floor(A1/3600,1)*3600 - floor((A1 - floor(A1/3600,1)*3600)/60, 1)*60,"00")
Let's break it down.
Get hours
FLOOR(A1/86400,1)*86400
A1- FLOOR(A1/86400,1)*86400
FLOOR((A1- FLOOR(A1/86400,1)*86400 )/3600, 1)
TEXT(FLOOR((A1- FLOOR(A1/86400,1)*86400 )/3600, 1), "00:")
Then, find remaining minutes and format it.
Then, take remaining seconds and format it.
=FLOOR(A6/86400, 1)
=A6-B6*86400
=FLOOR(C6/3600,1)
=C6-D6*3600
=FLOOR(E6/60, 1)
=E6-F6*60
=TEXT(D6,"00:") & TEXT(F6,"00:") & TEXT(G6,"00")
Upvotes: 0