Convert Serial number to Time

M

mudraker

Can someone pleae show me how to convert a decimal number to time in
VBA

0.249999999966667 = 6:00:00

Thanks In advance
 
M

mudraker

Dave

Thanks for your reply but that is not what i am after.

I have a serial number that I need to convert to time in a vba macro
anf then have the macro process more code
 
R

Ron Rosenfeld

Can someone pleae show me how to convert a decimal number to time in
VBA

0.249999999966667 = 6:00:00

Thanks In advance


---

That value is already equivalent to 6AM because of how Excel stores and
displays dates and times.

If you do something like:

Const dectime As Date = 0.249999999966667
MsgBox ("The time is: " & dectime)

The box will display: The time is 6:00:00 AM.

Since that's not quite what you specified, you'd need to format it more
precisely:

MsgBox ("The time is: " & Format(dectime, "h:mm:ss"))

In the latter case, dectime can be either a Date or a Double number type.


--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top