+ Reply to Thread
Results 1 to 5 of 5

transform text to a DD:HH:MM:SS format

  1. #1
    Registered User
    Join Date
    08-08-2011
    Location
    Reading, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    transform text to a DD:HH:MM:SS format

    Hi

    Looking for assistance writing a formula to transform the below entry to a DD:HH:MM:SS format.

    8d 15h 18m 54s

    I've tried manually manipulating using 'Find replace', and get the data to 8:15:18:54 ... however, this isn't recognised as a valid date format ...

    Any ideas welcomed

    Thanks
    Greg

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: transform text to a DD:HH:MM:SS format

    A few nested SUBSTITUTE functions...

    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C1," ",":"),"d",""),"h",""),"m",""),"s","")

    where C1 contains text
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,462

    Re: transform text to a DD:HH:MM:SS format

    You can format a time as dd:hh:mm:ss or as [hh]:mm:ss but first you'd have to convert the values from the text into a number representing a time.

    All you've done with the Find/Replace is convert one text value to another text value.

    A Time is a numeric value representing a part of a day. One (1) day is 24 hours, 15 hours is 15/24 of a day, 18 minutes is 18/(24*60) of a day.

    Extract the values using MID, multiply by their respective factors, add them up and format as required.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Registered User
    Join Date
    08-08-2011
    Location
    Reading, England
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: transform text to a DD:HH:MM:SS format

    Thanks both, appreciate your input

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: transform text to a DD:HH:MM:SS format

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save

+ 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