Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Decimal value to Time

Status
Not open for further replies.

sanjna000

Programmer
Aug 1, 2003
132
0
0
GB
Hi there,
Does anyone know how to convert decimal value to time?

eg: I need 3.75 convert into hh:mm format as 3:45

I really appriciate u r help...

Thanks a lot in advance!

Sanjna...


 
Try this:
Code:
Private Function DecToHHMM(NumVal As Single)
Dim HH As String
Dim MM As String
NumVal = 23.5
HH = Int(NumVal)
MM = Int(60 * ((NumVal / 1) - Int(NumVal)))
DecToHHMM = Format(HH & ":" & MM, "hh:mm")
End Function
Simon Rouse
 
Whoops - lose that NumVal=23.5, just there for testing
 
Thank you so much for u r help Simon...
Sanjna...
 

I'm sure you could have found an answer to this with a bit of effort. Read up on how dates are stored - this site is full of information in many threads. All you need is CDate(3.75/24).

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Thanks Tony. Really appriciate u r help!
Sanjna...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top