ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help subtracting time values (https://www.excelbanter.com/excel-programming/289852-need-help-subtracting-time-values.html)

TBA[_2_]

Need help subtracting time values
 
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-




Rob van Gelder[_4_]

Need help subtracting time values
 
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


--
Rob van Gelder - http://www.vangelder.co.nz/excel


"TBA" wrote in message
...
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-







All times are GMT +1. The time now is 03:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com