Results 1 to 4 of 4
  1. #1
    d.romanek is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Posts
    2

    Converting text field (00:00:00) to a time field


    Please help me. I am an intermediate Access user. I need to convert a text field containing a total amount of time (example: 128:15:52 -- 128 hour, 15 minutes, 52 seconds) as a time field. The data is imported into a database as a text field.

    Again, please put in non-programming term so that I can understand instructions! Thank you!

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    For the example that you gave: 128:15:52 . . . what do you want that converted to?

    Where will you be using the converted data - will it be in a query . . . a Form . . . ?

    A Time field [DateTime] usually just reports a point in time - for example 12/15/2012 9:27:00 [9:27 AM on Dec. 15th, 2012].
    Your 128:15:52 is not a particular point in time - but a measurement of an amount of time.

    Perhaps if you tell us exactly what you will do with the 128:15:52 . . . we will be able to assist.

  3. #3
    d.romanek is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    May 2013
    Posts
    2
    I export data regarding employee stats for a call center. For a particular period of time, the running amount of time is what I want to convert. The exported fields come across as text fields. So one employee may have an accumulated call time for the week of 40:13:24 (40 hours, 13 minutes, & 24 seconds). For my Access report, I need to convert that text field time to an actual time field so I can calculate sums and averages when I run queries gathering several days or months worth of data.

  4. #4
    Beetle is offline Unrelatable
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    Camp Swampy (Denver, CO)
    Posts
    207
    Well, you can't convert this to a time field because, as mentioned before, it's not a time value but a string of text that represents elapsed time. Elapsed time is actually a numeric value, not a time value, so you need to convert this to a number. In this case the lowest common denominator (so to speak) is seconds, so I would convert this value to total seconds with something like;

    Code:
    Left([ElapsedTime],InStr([ElapsedTime],":")-1)*3600+Mid([ElapsedTime],InStr([ElapsedTime],":")+1,2)*60+Right([ElapsedTime],2)
    You could do this in a calculated query field, then sum that calculated field for all records. Once you have the total seconds for the entire record set you can convert that value back with;

    Code:
    Format(Int([TotalTime]/3600),"00") & ":" & Format(Int(([TotalTime]-(Int([TotalTime]/3600)*3600))/60),"00") & ":" & Format((([TotalTime] Mod 60)),"00")
    Replace ElapsedTime and TotalTime in the above examples with your actual field names of course.

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

Similar Threads

  1. Converting time from text to time
    By virgilwilsonjr in forum Access
    Replies: 4
    Last Post: 01-11-2013, 10:05 AM
  2. Replies: 6
    Last Post: 12-16-2012, 08:43 AM
  3. Replies: 12
    Last Post: 06-04-2012, 10:55 AM
  4. Replies: 1
    Last Post: 08-07-2011, 07:58 AM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 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