+ Reply to Thread
Results 1 to 13 of 13

converting number string into time

  1. #1
    Registered User
    Join Date
    06-14-2010
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    22

    converting number string into time

    Hello all,

    I have a number string that came from a download from an AS/400 that I need to convert into time. An example of one of the cells is 93428, which I need to convert to 09:34:28. I have tried the format cells section with no luck and I'm reaching out to see if there is a solution out there.

  2. #2
    Forum Expert Whizbang's Avatar
    Join Date
    08-05-2009
    Location
    Greenville, NH
    MS-Off Ver
    2010
    Posts
    1,395

    Re: converting number string into time

    Assuming 93428 is located in cell A1, use the following formula.

    =IF(LEN(A1)=5,LEFT(A1,1),LEFT(A1,2))&":"&LEFT(RIGHT(A1,4),2)&":"&RIGHT(A1,2)

  3. #3
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: converting number string into time

    This should work if your data is text or number and placed in A1:
    =(LEFT(TEXT(A1,"000000"),2)&":"&MID(TEXT(A1,"000000"),3,2)&":"&RIGHT(TEXT(A1,"000000"),2))+0 and format as [h]:mm:ss

  4. #4
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: converting number string into time

    If A1 is a numeric value and that single digit minute / second values are stored with leading 0 then

    =TEXT(A1,"00\:00\:00")+0
    (cell format: [hh]:mm:ss)

    where A1 holds value

  5. #5
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: converting number string into time

    Try this, with 93428 in cell A1

    Please Login or Register  to view this content.

    This will return a time that can then be formatted to suit

    Hope this helps
    Last edited by Marcol; 07-15-2010 at 10:19 AM.
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  6. #6
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: converting number string into time

    FWIW, TIME approach will only work if value < 24 hours - the string based approach should work regardless.

  7. #7
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: converting number string into time

    or maybe
    =TIMEVALUE(SUBSTITUTE(TEXT(A1,"00-00-00"),"-",":"))
    ah posted after donkeyote id been playing with that for a while! \: hmmmm
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: converting number string into time

    @mdw: same holds true of TIMEVALUE of course... if you remove the TIMEVALUE call and manually coerce resulting string (eg 0+) you can avoid the >= 24 hour issue.

  9. #9
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: converting number string into time

    Hmmm.... ?

    All three methods seem to return the same result if the "string" has 5 or more characters (I tested up to1993428)
    Only mine fails if there are 4 or less, but if there are leading zeros all is well again.
    i.e. 3428 fails '03428 works.

    I'll get this formulae thing one day!

    Demo workbook attached.
    Attached Files Attached Files

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: converting number string into time

    Quote Originally Posted by Marcol
    All three methods seem to return the same result if the "string" has 5 or more characters (I tested up to1993428)
    Not so.

    Format the result cells as per earlier posts: [hh]:mm:ss (or General/Number)

    You will find that TIME related functions only ever relate to the decimal remainder (integer is ignored).

    The TEXT method with manual coercion (ie 0+ rather than use of TIME related function) will return the cumulative time - ie inclusive of complete days.

  11. #11
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: converting number string into time

    Hi DonkeyOte

    Okay the penny's finally dropped.

    I was testing with hh:mm:ss not [hh]:mm:ss and never thought of checking the results as general numbers.

    Another lesson learned!

    Thanks for the explanation, I hope it benefits paintballlovr as much as it has me.
    Last edited by Marcol; 07-15-2010 at 12:11 PM.

  12. #12
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326

    Re: converting number string into time

    Hope the OP is still with us.... :-)

  13. #13
    Registered User
    Join Date
    06-14-2010
    Location
    Iowa
    MS-Off Ver
    Excel 2010
    Posts
    22

    Re: converting number string into time

    I'm still here and hanging on for dear life.

    I haven't had a chance to try any of the suggestions yet, but a hearty thank you to everyone who has posted so far.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1