converting seconds to hours, minutes, seconds

admiral_Tristan

Board Regular
Joined
Dec 18, 2002
Messages
127
Hello,

I have a cell which contains a total amount of seconds. I need this number expressed in terms of hours,minutes,and seconds logged in. Now my problem is that sometimes the seconds may not total 1 hour or even 1 minute, so I need the formula to then just display the seconds. IE

123543--expressed in hours, minutes, seconds
53--would just show minutes
5--would just show seconds.

Anyone know how I can do this?
 
admiral_Tristan said:
I need this number expressed in terms of hours,minutes,and seconds... Anyone know how I can do this?

so I need the formula to then just display the seconds.

i don't understand. do you want just seconds? or days...hours...minutes...second?
 
Upvote 0
Would this do?
Book3
ABCD
1Seconds
2UnformattedFormatted
30:mm:ss"))]:00
45:05
550:50
65008:20
750001:23:20
8250006:56:40
925000069:26:40
Sheet1


Formula in B3:B9 is =TEXT(A5/86400,CHOOSE(MATCH(A5,{0,60,3600},1),":ss","m:ss","[h]:mm:ss"))

Alternate output:
=TEXT(A2/86400,CHOOSE(MATCH(A2,{0,60,3600},1),"s ""sec""","m ""min"" s ""sec""","[h] ""hrs"" m ""min"" s ""sec"""))
 
Upvote 0
That's a nice one Greg, :beerchug:

but since it took some effort before I found the right workbook on my HDD, I'll post it anyway...

123456 is:
1 day(s), 10 hour(s), 17 minutes, 36 seconds
=INT(1/86400*A1) &" day(s), "& INT(MOD(A1;86400)/3600) & " hour(s), " & INT(MOD(A1;3600)/60) &" minutes, " & MOD(A1;60) &" seconds"

or
34 hour(s), 17 minutes, 36 seconds
= INT(A1/3600) & " hour(s), " & INT(MOD(A1;3600)/60) &" minutes, " & MOD(A1;60) &" seconds"

Martin
 
Upvote 0
greg you are the man, thats a great perfect formula. my manager is going to think I'm great now!!

:diablo:

thanks for all your help, I'm always amazed at the speed and quality of the replies on this board. truly excellent
 
Upvote 0
Aside from Greg's slick formula, another approach would be to use custom formatting, as below--
MrE1254.xls
ABCD
1SecondsCustom
2UnformattedFormat
30:00CellsB3:B9customformat:
459:59[>0.041666][h]:mm:ss;[>0.000694]m:ss;\:ss
5601:00
6359959:59
736001:00:00
8250006:56:40
925000069:26:40
Sheet10
 
Upvote 0
Tom, I'd've done it thattaway if I'd've known I could do it thattaway! Just learned something new. Thanks! :bow:
 
Upvote 0

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top