-
Hi,
I am trying to get the difference if time and I am having problem, here is my code, any help is appretiated. Thanks in advance!
Dim MyTime As Date
Dim MyMinute As Date
Dim m As Date
Dim m2 As Date
Dim h As Date
MyTime = #6:35:17 PM# ' Assign a time.
m = #5:30:17 PM# ' Assign a time.
MyMinute = Minute(MyTime) ' MyMinute contains 35.
If MyTime > m Then
h = Hour(MyTime) - Hour(m)
If h >= 0 Then
m2 = Minute(MyTime) - Minute(m)
h = m2 + h
MsgBox h
End If
End If
-
I could be confusing you here, but one approach would be to convert both times into seconds, do the subtraction, then convert the result back into hhmmss.
-
How about using a simple function:
DateDiff(interval, date1, date2)
where interval can be set to:
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second
Hope you can use it