+ Reply to Thread
Results 1 to 3 of 3

Convert Text to Duration

  1. #1
    Registered User
    Join Date
    03-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Convert Text to Duration

    Hello,

    I have a column of duration data formatted as text. It's in the format, for example, 2d 12h 15m. If it's less than a day, it won't have the d field. I'd like to convert this text to a duration or date that I can then use to make averages, etc. Any help would be appreciated.

    Thanks,
    Brett

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: Convert Text to Duration

    brettdowden,

    Welcome to the forum!
    You can use this formula to convert the text into a usable date/time number:
    =IF(COUNTIF(A1,"*d*"),LEFT(A1,SEARCH("d",A1)-1),0)+MID(A1,SEARCH("h",A1)-2,2)/24+MID(A1,SEARCH("m",A1)-2,2)/1440

    The results will be the number of days, and then a fraction of a day representing the hours and minutes. Format the cell containing the result as custom with:
    [h]:mm;@

    Using the example you provided, 2d 12h 15m, the result will be:
    60:15 (60 hours, 15 minutes)
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    03-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: Convert Text to Duration

    Thank you so much. I just had to make a slight variation for the cases where there was no "d" portion AND there was only 1 hour digit. Once you gave me the starting point, I could figure it out.

    Brett

+ 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