ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   convert a number of seconds to HH:MM:SS? (https://www.excelbanter.com/excel-programming/301868-convert-number-seconds-hh-mm-ss.html)

Steff_DK[_21_]

convert a number of seconds to HH:MM:SS?
 
I use timer in my code.
It calculates the time elapsed by subtracting a number of seconds fro
another number of seconds e.g. 50256.3470 - 40155.1

The value returned, should be in the format HH:MM:SS.

How is this done in code?

I dont want to write any functions into ranges on the sheet or forma
any cells...

Thanks!!

--
Message posted from http://www.ExcelForum.com


JWolf

convert a number of seconds to HH:MM:SS?
 
Divide the formula by 86400 and format the cell as hh:mm:ss.
86400=24 hrs*60min*60seconds. Excel stores time as the decimal fraction
of one day. i.e. 12:00:00=0.5, 18:00:00=0.75, etc.

Steff_DK < wrote:
I use timer in my code.
It calculates the time elapsed by subtracting a number of seconds from
another number of seconds e.g. 50256.3470 - 40155.1

The value returned, should be in the format HH:MM:SS.

How is this done in code?

I dont want to write any functions into ranges on the sheet or format
any cells...

Thanks!!!


---
Message posted from http://www.ExcelForum.com/


JWolf

convert a number of seconds to HH:MM:SS?
 
OK, no format:
range("A1").value=format(yourFormula/86400,"hh:mm:ss")

JWolf wrote:

Divide the formula by 86400 and format the cell as hh:mm:ss.
86400=24 hrs*60min*60seconds. Excel stores time as the decimal fraction
of one day. i.e. 12:00:00=0.5, 18:00:00=0.75, etc.

Steff_DK < wrote:

I use timer in my code. It calculates the time elapsed by subtracting
a number of seconds from
another number of seconds e.g. 50256.3470 - 40155.1
The value returned, should be in the format HH:MM:SS.

How is this done in code?

I dont want to write any functions into ranges on the sheet or format
any cells...

Thanks!!!


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 04:05 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com