Re: [RESOLVED] adding in military time
i forgot about this ..im sorry
Abs(elasped)
Re: [RESOLVED] adding in military time
You should not be using strings for math, very bad practice.
Re: [RESOLVED] adding in military time
is this right with military time
Code:
Private Sub Command3_Click()
Dim start1 As Double
Dim stop1 As Double
Dim elasped As Double
Dim offset As Double
offset = Val("24.")
start1 = Val("23.")
stop1 = Val("1.")
elasped = stop1 - start1
MsgBox elasped
If elasped < 0 Then
elasped = offset - Abs(elasped)
MsgBox elasped
Else
MsgBox elasped
End If
End Sub
Re: adding in military time
Why use strings at all? why not:-
code Code:
Dim start1 As Double
Dim stop1 As Double
Dim elasped As Double
Dim offset As Double
offset = 24
start1 = 23
stop1 = 1
And you don't need that ABS because you're only subtracting it from offset if it's negative. Why not just do this:-
code Code:
elasped = offset + elasped
Re: adding in military time
that works but the time should be 2300 or 0100
Re: adding in military time
You should be using two date objects, and then using DateDiff to get the difference in hours.... the fact that it's "Military time" is irrelevant as that's just display...
-tg
Re: adding in military time
im tring to get the difference in hours , but the time may start at anytime 11:00 pm wait form 24 or more hours and restart.
Re: adding in military time
all the more reason to use a date variable.... the difference between 6/27/2012 11:00pm and 6/28/2012 1:00am is 2 hours... but the 6/27/2012 11:00pm and 6/29/2012 1:00am is 26 hours...
-tg
Re: adding in military time
No doubt you should be using a date variable and the datediff() function. If you need it displayed a certian way then you just use a format() function to get the desired result.
Re: adding in military time
hey yall why does this show an hour even when its only been 40 minutes?
does it round off the numbers?
Code:
If timelimit = "" Then timelimit = Format(Now())
timenow = Format(Now())
Label1.Caption = timelimit
Label2.Caption = Format(Now())
Label3.Caption = DateDiff("h", timelimit, timenow)
datdiff = DateDiff("h", timelimit, timenow)
Re: adding in military time
hey yall timelimit is 12 and 1/2 hours ago why does this code round off to nearest number?
Code:
timenow = Format(Now())
datdiff = DateDiff("h", timelimit, timenow)