|
-
Jul 10th, 2006, 12:16 PM
#1
Thread Starter
Hyperactive Member
Format time to decimals of seconds?
HI,all.
how can i format the line of code bellow to have the decimals of seconds?
VB Code:
data_time = Format(datacurr_tempo, "hh:mm:ss")
Thanks.
-
Jul 10th, 2006, 12:25 PM
#2
Re: Format time to decimals of seconds?
Give an example of the output you want?
Last edited by penagate; Jul 10th, 2006 at 12:36 PM.
-
Jul 10th, 2006, 12:27 PM
#3
Re: Format time to decimals of seconds?
I think this is what he's looking for:
90 seconds = 1min 30sec = 1.5 min....
There isn't a way to do so with the format function.... you'll need to create your own. The calculation is simple though, get the number of seconds remaining and divide by 60... that will give you the decimal minute.
-tg
-
Jul 10th, 2006, 12:35 PM
#4
Re: Format time to decimals of seconds?
Hmm... I think he wants the output to looks something like 7:31:23.127 (hh:mm:ss.decimals). To be honest I don't think you can do that with the normal date/time functions since they don't contain fractions of a second.
-
Jul 10th, 2006, 12:37 PM
#5
Thread Starter
Hyperactive Member
Re: Format time to decimals of seconds?
Hi, Techgnome and Penagate.
Thanks, but i think you guys didn´t understand what i´m looking for, what i want to do is
save the system time in (hh:mm:ss:??) decimal of the seconds.
Ok, if this is not possible how can i add a second to a given time?
Thanks.
-
Jul 10th, 2006, 12:41 PM
#6
Re: Format time to decimals of seconds?
You can add a second to a time using the DateAdd function.
VB Code:
MsgBox DateAdd("s", 1, Now) 'add 1 second to the current date/time
-
Jul 10th, 2006, 12:45 PM
#7
Re: Format time to decimals of seconds?
VB Code:
Private Declare Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Sub Form_Load()
Dim sTime As SYSTEMTIME
GetLocalTime sTime
With sTime
Debug.Print .wHour & ":" & .wMinute & ":" & .wSecond & "." & .wMilliseconds
End With
End Sub
-
Jul 10th, 2006, 12:55 PM
#8
Thread Starter
Hyperactive Member
Re: Format time to decimals of seconds?
Thanks, Bushmobile.
But now i have another question?
- His possible to compare times in this way?,like for example:
if time1>time2 then
Thanks again?
-
Jul 10th, 2006, 01:00 PM
#9
Re: Format time to decimals of seconds?
sure, just compare the numbers.
however if you're looking to measure short periods of time then you should check out the GetTickCount API and the more accurate QueryPerformance APIs
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|