+ Reply to Thread
Results 1 to 16 of 16

How to convert time in text i.e. 19minutes and 40 seconds to time

  1. #1
    Registered User
    Join Date
    08-23-2017
    Location
    California, United States
    MS-Off Ver
    2013
    Posts
    4

    Question How to convert time in text i.e. 19minutes and 40 seconds to time

    I have a large file with duration in the format 19 minutes and 40 seconds or 1 hour, 37 minutes and 16 seconds etc. I need to convert this to time to perform calculations like average. I have tried Data -> text to column, doesn't help. Thanks in advance.
    Attached Files Attached Files
    Last edited by axy5093; 08-23-2017 at 12:44 PM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    08-23-2017
    Location
    California, United States
    MS-Off Ver
    2013
    Posts
    4

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Thanks, I have added an attachment of the sample data, i need it in any valid time format so as to be able to perform calculations.

  4. #4
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Enter array formula in B2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Format as Custom, hh:mm:ss
    v A B
    1 Total Duration
    2 19 minutes and 40 seconds 00:19:40
    3 11 minutes and 24 seconds 00:11:24
    4 42 minutes and 19 seconds 00:42:19
    5 11 hours, 4 minutes and 42 seconds 01:14:42
    6 43 minutes and 31 seconds 00:43:31
    7 29 minutes and 20 seconds 00:29:20
    8 36 minutes and 1 second 00:04:01
    9 28 minutes and 37 seconds 00:28:37
    10 1 hour, 25 minutes and 26 seconds 01:25:26
    11 23 minutes and 30 seconds 00:23:30
    12 23 minutes and 44 seconds 00:23:44
    13 40 minutes and 48 seconds 00:40:48
    14 30 minutes and 13 seconds 00:30:13
    15 26 minutes and 53 seconds 00:26:53
    16 1 hour, 1 minute and 1 second 00:01:11
    17 26 minutes and 44 seconds 00:26:44
    18 39 minutes and 20 seconds 00:39:20
    19 44 minutes and 45 seconds 00:44:45
    20 1 hour, 37 minutes and 16 seconds 01:37:16
    21 40 minutes and 57 seconds 00:40:57
    22 30 minutes and 53 seconds 00:30:53
    23 1 hour, 24 minutes and 45 seconds 01:24:45
    24 2 hours, 6 minutes and 52 seconds 00:26:52
    25 38 minutes and 8 seconds 00:04:28
    26 43 minutes and 32 seconds 00:43:32
    27 1 hour, 18 minutes and 18 seconds 01:18:18
    28 1 hour, 22 minutes and 9 seconds 00:12:29
    29 30 minutes and 48 seconds 00:30:48
    30 1 hour, 19 minutes and 42 seconds 01:19:42
    Attached Files Attached Files
    Last edited by AlKey; 08-23-2017 at 12:57 PM.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  5. #5
    Registered User
    Join Date
    08-23-2017
    Location
    California, United States
    MS-Off Ver
    2013
    Posts
    4

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Hi, Thank you. This is perfect. If you don't mind could you please explain it to me. I am new to excel and would like to learn.

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    AlKey, that is very clever.
    Entia non sunt multiplicanda sine necessitate

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    I'm sure there's a far more elegant way to do it but this formula worked for me.

    =TIMEVALUE(IF(ISERROR(SEARCH("hour", A2)), "00:", "")&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"and ",""), " seconds", ""), " second",""), " minutes ", ":"), "minute ",":"), " hour, ", ":"), " hours, ",":"))

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    @ AlKey: Oops: Lines 16, 24, 25, 28

    @ Norie: Nice, but fails for "1 hour and 1 second"
    Last edited by shg; 08-23-2017 at 01:14 PM.

  9. #9
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    hey AlKey, I like it and was thinking of borrowing it but I'm wondering if the formula breaks at row 5 where it should read 11:04:42 but instead comes out as 01:14:42?
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  10. #10
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    OR,

    Try the following in B2:

    =TIME(IFERROR(1*LEFT(A2,SEARCH("hour",A2)-2),0),IFERROR(1*MID(A2,SEARCH("minute",A2)-3,2),0),1*MID(A2,SEARCH("Second",A2)-3,2))
    Attached Files Attached Files

  11. #11
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Quote Originally Posted by shg View Post
    @ AlKey: Oops: Lines 16, 24, 25, 28

    @ Norie: Nice, but fails for "1 hour and 1 second"
    Yea, there are quite few that fail It happens when strings contains single numbers like 1 instead of 01. Maybe corrections can be made at the source.

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    It's still a clever formula, and I don't know how it works.

  13. #13
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Quote Originally Posted by shg View Post
    It's still a clever formula, and I don't know how it works.
    I found this formula (and it's variants) long time ago but I was never able to find a person who wrote it. Neither I was able to find any explanation on how this formula really works. I used it on few rare occasion when I needed to pull numbers out strings.

  14. #14
    Registered User
    Join Date
    08-23-2017
    Location
    California, United States
    MS-Off Ver
    2013
    Posts
    4

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    @cbatrody Your formula works well except in case of only minutes like 43 minutes. Thank you.
    @AlKey Thanks, am not sure how it works but does the job!

  15. #15
    Forum Expert cbatrody's Avatar
    Join Date
    04-15-2014
    Location
    Dubai
    MS-Off Ver
    Microsoft Office 365 ProPlus
    Posts
    2,136

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Try the following in B2:

    =TIME(IFERROR(1*LEFT(A2,SEARCH("hour",A2)-2),0),IFERROR(1*MID(A2,SEARCH("minute",A2)-3,2),0),IFERROR(1*MID(A2,SEARCH("Second",A2)-3,2),0))
    Attached Files Attached Files

  16. #16
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: How to convert time in text i.e. 19minutes and 40 seconds to time

    Well, my solution is almost identical to @cbatrody in post#10, though a little shorter. I also included error checking for zero seconds.
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and use Thread Tools (up top) to mark your thread as SOLVED once you have your answer. Thanks!-Lee
    Last edited by leelnich; 08-23-2017 at 03:37 PM.

+ 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. [SOLVED] How to Convert date or time into seconds
    By Arpita_Excel in forum Excel General
    Replies: 6
    Last Post: 06-11-2015, 02:13 AM
  2. [SOLVED] Convert time in seconds to 00:00:00 format
    By icyrius in forum Excel General
    Replies: 2
    Last Post: 10-17-2013, 04:31 PM
  3. time question:convert into seconds
    By stevesunfold in forum Excel General
    Replies: 2
    Last Post: 07-26-2007, 12:29 PM
  4. How to convert time into seconds.
    By mangesh in forum Excel General
    Replies: 3
    Last Post: 06-26-2006, 07:25 PM
  5. Convert Seconds and decimals to time
    By bagoxc in forum Excel General
    Replies: 5
    Last Post: 01-03-2006, 07:41 PM
  6. Convert time to all seconds
    By glenlee in forum Excel General
    Replies: 2
    Last Post: 03-12-2005, 12:07 PM
  7. [SOLVED] Convert seconds to time
    By Tod in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-10-2005, 08:06 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