+ Reply to Thread
Results 1 to 8 of 8

How to change the values to Minutes/ Hours

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    12

    Exclamation How to change the values to Minutes/ Hours

    I need to change the following value in excel cell to Minutes/ Seconds.. How to do it with the help of formula?

    Cell = "0d 2h 18m 27s"

  2. #2
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to change the values to Minutes/ Hours

    Not sure if we have all of the details, but

    With
    A1 containing date/time text in the format you posted.....0d 2h 18m 27s

    This formula converts that value into an Excel date/time, which you can format any way you like
    B1: =--(LEFT(A1,SEARCH("d",A1)-1)*24
    +TRIM(RIGHT(LEFT(A1,SEARCH("h",A1)-1),2))
    &":"&TRIM(RIGHT(LEFT(A1,SEARCH("m",A1)-1),2))
    &":"&TRIM(LEFT(RIGHT(A1,3),2)))
    In the above example, that formula returns: 0.0961458333333333

    When custom number formatted as [m]:ss
    the result displays as: 138:27

    Is that something you can work with?
    Last edited by Ron Coderre; 05-13-2015 at 10:11 AM.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  3. #3
    Registered User
    Join Date
    05-13-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    12

    Re: How to change the values to Minutes/ Hours

    Hi Ron... This is just brilliant... However, there's a little issue here..

    No of Days can go up to 31 days.. whereas in my example it is 0 days and it seems that the formula is working upto only single digit dates


    Hours/ minutes and Seconds can also be upto 2 digits.. so the formula needs to take care of double digits as well as single digits..

    Any solution possible

    For example.. the formula is giving an incorrect value for "20d 17h 20m 34s".. The formula result is '5200060' where as the actual value should be '102460'.
    Last edited by nitin_bidi; 05-13-2015 at 10:24 AM.

  4. #4
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to change the values to Minutes/ Hours

    I'm not seeing that.

    For this input: 20d 17h 20m 34s

    The text part of the formula I posted resolves to this: "497:20:34"

    Converted to a number, "497:20:34" becomes: 20.7226157407407

    When that value has a custom number format of [m]:ss
    the result is: 29840:34

    20*24+17 = 497 hours


    497 hours = 29820 minutes
    +20 min = 29840
    +34 sec = 29840:34 (which is what the formula I posted returns)

    What am I missing?

  5. #5
    Registered User
    Join Date
    05-13-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    12

    Re: How to change the values to Minutes/ Hours

    Apologies Ron !! You are correct, the formula works fine ..

    I restarted my excel and now it is picking up the correct values.

    You are superb !!Thanks again !!

  6. #6
    Registered User
    Join Date
    05-13-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    12

    Re: How to change the values to Minutes/ Hours

    One question Sir !! when you write "-1),2))" in a formula, what does it indicate? And what is the relevance of &": in the formula

  7. #7
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: How to change the values to Minutes/ Hours

    After finding the position of a character (like "d") in the string, we don't want to include it in the numeric portion.
    Example:
    to extract the number of days from 20d
    LEFT(A1,SEARCH("D",A1)) would return 20d
    but, this...LEFT(A1,SEARCH("D",A1)-1) returns 20

    The "&" is used for string concatenation. It makes the CONCATENATE function unnecessary.

    This: CONCATENATE("A","B","C")
    is the same as this: "A"&"B"&"C".

    Both approaches return: "ABC"

  8. #8
    Registered User
    Join Date
    05-13-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    12

    Re: How to change the values to Minutes/ Hours

    Thanks a lot !! Will remember you for the learning you have imparted !! Have a nice day !!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Change hours:minutes:seconds to days
    By jwahl16 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-17-2013, 02:25 PM
  2. Replies: 13
    Last Post: 05-03-2013, 08:42 PM
  3. Replies: 2
    Last Post: 01-08-2008, 10:51 PM
  4. [SOLVED] change minutes to hours and minutes
    By Steved in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-05-2006, 10:00 PM
  5. Replies: 2
    Last Post: 11-05-2005, 12:25 PM

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