Need help subtracting time values

  • Thread starter Thread starter TBA
  • Start date Start date
T

TBA

Excel 2000
Windows 2k Pro

I have a column of time values in a dbf file from a GPS unit. The time
values are in military time format, i.e. "16:34:27" and they are written to
the dbf as string values. I'm having a hard time figuring out how to do
simple subtraction with them. Should I store them as String values or as
Variants? I've tried both with little success. Any help greatly
appreciated. Thanks!

-gk-
 
You could store them as Date... Subtraction can be performed on Dates and
you can do date/time formatting with it too.

Sub test()
Dim dtm1 As Date, dtm2 As Date

dtm1 = CDate("12:30:00")
dtm2 = CDate("16:34:27")

MsgBox Format(dtm2 - dtm1, "hh:mm:ss")
End Sub
 
Back
Top