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

Time formatting

Status
Not open for further replies.

rgbanse

MIS
Jun 4, 2001
211
US
Format(Now(), "hh:nn:ss") will yield 01:15:31
is there a format command to yield 01:15:31:45
thx
Jerry
 
I found this DateDifference Function in another area and modified it to include the seconds portion. You could 'adjust' it to work for you by changing the final
DateDifference = .... so that only the 00:00:00:00 portion is returned.
------------------------------------

Public Function DateDifference(Date1 As Date, Date2 As Date) As String
Dim days As Double
Dim hours As Double
Dim minutes As Double
Dim seconds As Double
Dim difference As Double

difference = Date1 - Date2
days = Int(difference)
hours = 24 * (difference - days)
minutes = (hours - Int(hours)) * 60
seconds = (minutes - Int(minutes)) * 60

DateDifference = Format$(days, "0") & ":" _
& Format$(hours, "0") & ":" _
& Format$(minutes, "0") & ":" _
& Format$(seconds, "0") & " (" _
& Format$(days, "0") & " days, " _
& Format$(hours, "0") & " hours, " _
& Format$(minutes, "0") & " minutes, " _
& Format$(seconds, "0") & " seconds)"
End Function
 
No, the smallest increment returned is seconds, so hh:nn:ss is as precise as it will give you in a date format.
 
So sorry, I miss read the original question (seeing the format of it as dd:hh:mm instead of hh:mm:ss)

taz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top