Results 1 to 5 of 5
  1. #1
    virgilwilsonjr is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    3

    Arrow Converting time from text to time

    I have a program that outputs time elapsed as a text format than a time format.

    The fields are

    Time Updated - 07:15:49.312
    Lap Time - 00:13:29.312
    Elapsed Time - 00:13:29.312



    I would like to be able to add the lap times to get the elapsed time.

    Thanks for any help you can give me.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,974
    Need to get the time parts into same units. One way is to create a custom function:

    Function GetLapTimeSeconds(strTime As String) As Double
    Dim x As Variant
    If strTime <> "" Then
    x = Split(strTime, ":")
    GetLapTimeSeconds = x(0) * 3600 + x(1) * 60 + x(2)
    End If
    End Function

    Call that function in a query to convert the lap times into seconds. Sum that calculated field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    virgilwilsonjr is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    3
    Sorry I'm a newbie with the more advanced topics with Access. How do I call a custom function in a query?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,974
    Put the function code in a general VBA module. In query designer, create a field with expression. In this case the expression is a call to function:

    ConvertLap: GetLapTimeSeconds([Lap Time])

    An alternative to the function call is this expression I didn't think of earlier:

    Left([Lap Time],2) * 3600 + Mid([Lap Time],4,2) * 60 + Mid([Lap Time],7)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    virgilwilsonjr is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    3
    Thanks for your help

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Converting a string to date/time
    By RayMilhon in forum Programming
    Replies: 8
    Last Post: 09-28-2012, 10:02 AM
  2. Converting UNIX time
    By sharon.chapman7 in forum Programming
    Replies: 3
    Last Post: 09-02-2011, 08:32 AM
  3. Replies: 6
    Last Post: 01-04-2011, 05:43 PM
  4. Converting a date to length of time
    By Duncan in forum Access
    Replies: 2
    Last Post: 11-10-2010, 05:53 AM
  5. Replies: 2
    Last Post: 07-03-2010, 08:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums