calculate time segments

  • Thread starter Thread starter John boy
  • Start date Start date
J

John boy

I'm working with txt file (comma delimited)- one of the columns of data has
time segments (00:23:33). In other words the time I have shown in parenthesis
indicates a duration of 23 minutes and 33 seconds. Access does not import
these time segments if the first segment is 00 because it is trying to
convert to a time of day. Ultimately, I will need to perform calculations
with this field (add time segments etc., Any suggestions?
 
I'm working with txt file (comma delimited)- one of the columns of data has
time segments (00:23:33). In other words the time I have shown in parenthesis
indicates  a duration of 23 minutes and 33 seconds. Access does not import
these time segments if the first segment is 00 because it is trying to
convert to a time of day. Ultimately, I will need to perform calculations
with this field (add time segments etc.,  Any suggestions?

one option is to store them in your database as text and then convert
them to time durations with a query.
if the format is always HH:MM:SS, then
Hours: CInt(Left(TimeString),2)
Minutes: CInt(Mid$(TimeString,4,2))
Seconds: Cint(Right$(TimeString,2))
Then you can do something like convert to seconds (lowest common
denominator sort of thing) and add...
 
It should not be stored as a date/time value. A date/timve data type
represents a specific point in time. 23 minutes and 33 seconds is not a time,
but a duration.

I would suggest you convert it to a long integer that represents the number
of seconds. You can then break it back out to minutes and seconds to display
it to users, but using it in calculations, seconds would be best because it
would make the calculation simpler. if the representation is HH:MM:SS then

Dim strTimeString As String
Dim lngSecs as Long

lngSecs = (CLng(Left(strTimeString,2)) * 3600) +
(CLng(Mid(strTimeString,4,2)) *60) + (CLng(Right(strTimeString,2))
 
Back
Top