+ Reply to Thread
Results 1 to 7 of 7

how do I convert a general number to a time format?

  1. #1
    doveness
    Guest

    how do I convert a general number to a time format?

    I'm trying to conver 425033 to 42:50:30

    I'm running out of steam!

  2. #2
    Dave Sheldon
    Guest

    Re: how do I convert a general number to a time format?

    You can parse the string with
    =LEFT(A1,2)&":"&MID(A1,3,2)&":"&RIGHT(A1,2)

    Dave

    "doveness" <[email protected]> wrote in message
    news:[email protected]...
    > I'm trying to conver 425033 to 42:50:30
    >
    > I'm running out of steam!




  3. #3
    Pete_UK
    Guest

    Re: how do I convert a general number to a time format?

    Dave's formula will return a text result which will look like a time.
    If you want the result in true Excel time format (numeric) then you
    will have to put VALUE( ... ) around his formula and format the cell
    using a custom format of [hh]:mm:ss.

    Hope this helps.

    Pete


  4. #4
    Gary''s Student
    Guest

    Re: how do I convert a general number to a time format?

    Hi Dave:

    Good answer.

    A slight variation will give a time in standard numerical format:

    =LEFT(A1,2)/24+MID(A1,3,2)/(24*60)+RIGHT(A1,2)/(24*60*60)
    format as [hh]:mm:ss
    --
    Gary's Student


    "Dave Sheldon" wrote:

    > You can parse the string with
    > =LEFT(A1,2)&":"&MID(A1,3,2)&":"&RIGHT(A1,2)
    >
    > Dave
    >
    > "doveness" <[email protected]> wrote in message
    > news:[email protected]...
    > > I'm trying to conver 425033 to 42:50:30
    > >
    > > I'm running out of steam!

    >
    >
    >


  5. #5
    gublues
    Guest

    Re: how do I convert a general number to a time format?

    If you have hrs between 1 and 10 you will have only 5 numbers and only the
    RIGHT formula will give correct answer.
    Then you have to modify your formula like this:
    =IF(LEN(A1)=5;"0"&LEFT(A1;1)&":"&MID(A1;2;2)&":"&RIGHT(A1;2);LEFT(A1;2)&":"&MID(A1;3;2)&":"&RIGHT(A1;2))

    if below 1 hrs you maybe have only 4.
    Then you have to modify even further:
    =IF(LEN(A1)=4;"00"&":"&MID(A1;1;2)&":"&RIGHT(A1;2);IF(LEN(A1)=5;"0"&LEFT(A1;1)&":"&MID(A1;2;2)&":"&RIGHT(A1;2);LEFT(A1;2)&":"&MID(A1;3;2)&":"&RIGHT(A1;2)))

    *gublues


    Gary''s Student skrev:

    > Hi Dave:
    >
    > Good answer.
    >
    > A slight variation will give a time in standard numerical format:
    >
    > =LEFT(A1,2)/24+MID(A1,3,2)/(24*60)+RIGHT(A1,2)/(24*60*60)
    > format as [hh]:mm:ss
    > --
    > Gary's Student
    >
    >
    > "Dave Sheldon" wrote:
    >
    > > You can parse the string with
    > > =LEFT(A1,2)&":"&MID(A1,3,2)&":"&RIGHT(A1,2)
    > >
    > > Dave
    > >
    > > "doveness" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > I'm trying to conver 425033 to 42:50:30
    > > >
    > > > I'm running out of steam!

    > >
    > >
    > >


  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    A simpler way.....

    =TEXT(A1,"00\:00\:00")+0

    format as [h]:mm:ss

  7. #7
    Gary''s Student
    Guest

    Re: how do I convert a general number to a time format?

    Your comments are correct. The formula is designed to handle 6 digit
    quantities that can be mapped: hhmmss

    It will fail for hours less than 10.
    It will fail for hours greater than 99.

    The formula will, however, handle numbers as per the OP's spec.
    --
    Gary's Student


    "gublues" wrote:

    > If you have hrs between 1 and 10 you will have only 5 numbers and only the
    > RIGHT formula will give correct answer.
    > Then you have to modify your formula like this:
    > =IF(LEN(A1)=5;"0"&LEFT(A1;1)&":"&MID(A1;2;2)&":"&RIGHT(A1;2);LEFT(A1;2)&":"&MID(A1;3;2)&":"&RIGHT(A1;2))
    >
    > if below 1 hrs you maybe have only 4.
    > Then you have to modify even further:
    > =IF(LEN(A1)=4;"00"&":"&MID(A1;1;2)&":"&RIGHT(A1;2);IF(LEN(A1)=5;"0"&LEFT(A1;1)&":"&MID(A1;2;2)&":"&RIGHT(A1;2);LEFT(A1;2)&":"&MID(A1;3;2)&":"&RIGHT(A1;2)))
    >
    > *gublues
    >
    >
    > Gary''s Student skrev:
    >
    > > Hi Dave:
    > >
    > > Good answer.
    > >
    > > A slight variation will give a time in standard numerical format:
    > >
    > > =LEFT(A1,2)/24+MID(A1,3,2)/(24*60)+RIGHT(A1,2)/(24*60*60)
    > > format as [hh]:mm:ss
    > > --
    > > Gary's Student
    > >
    > >
    > > "Dave Sheldon" wrote:
    > >
    > > > You can parse the string with
    > > > =LEFT(A1,2)&":"&MID(A1,3,2)&":"&RIGHT(A1,2)
    > > >
    > > > Dave
    > > >
    > > > "doveness" <[email protected]> wrote in message
    > > > news:[email protected]...
    > > > > I'm trying to conver 425033 to 42:50:30
    > > > >
    > > > > I'm running out of steam!
    > > >
    > > >
    > > >


+ 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