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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convertime a decimal time figure into a true time figure

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

Does anyone know the formula that converts decimal time into true time?
i.e. 2.5 hrs (dec) = 2:30 (true time)

I would appreciate your help with this , otherwise I will have to struggle to write it myself.

Thanks in advance

Steven
 
Assuming the output can be a string, you could use the following function:

Public Function TrueTime(DecTime As Double) As String
Dim intTime As Integer
Dim dblMinutes As Double

intTime = Int(DecTime)
dblMinutes = DecTime - intTime

TrueTime = Format$(intTime, "0") & ":" & Format$(dblMinutes * 60, "00")

End Function
 
? format(2.5/24, "Short Time")
02:30


Hint the hint is in the denominator!

Another Hint. DO NOT try this at home with Numerator > Denominator.

MichaelRed
mred@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top