+ Reply to Thread
Results 1 to 6 of 6

Extract the time from a text string

  1. #1
    Registered User
    Join Date
    01-07-2008
    Posts
    19

    Extract the time from a text string

    I need to extract the time from various text strings, example below:

    "Killar 16th Jul - 18:15 2m4f Hcap Chs"

    The problem is that the length of the text before and after the time vary. The only constant is the "- " before the time.

    Also, I need the result to be in time format, hh:mm.

    Many thanks

  2. #2
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    Hi

    Assuming that data in A1 then try:

    =MID(A1,FIND("- ",A1)+2,5)+0

    Format the resulting formula cell as

    hh:mm

    to display it in your desired format.

    Richard

  3. #3
    Registered User
    Join Date
    07-18-2008
    Location
    India
    Posts
    68

    Extract the time from a text string

    Hi,

    Instead of using find, use search function.

    e.g. (assuming data is in cell A1)

    =MID(A1,SEARCH("-",A1)+1,6)

  4. #4
    Valued Forum Contributor Richard Schollar's Avatar
    Join Date
    05-23-2006
    Location
    Hampshire UK
    MS-Off Ver
    Excel 2002
    Posts
    1,264
    OK you've piqued my interest - why would you use SEARCH over FIND?

  5. #5
    Forum Contributor
    Join Date
    07-24-2008
    Location
    Athome
    MS-Off Ver
    Excel 2013
    Posts
    127
    find is case sensitive, search is not.

    in this instance it shouldn't make a difference

  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
    I'd expect that FIND is slightly faster for that reason.

+ 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