简体   繁体   中英

Excel extract text between identical characters

I want to extract the date from the following text:

Thu 11/29/18

I was thinking to use MID function however the length of the month can change depending on the month (eg 1 vs 10). Likewise the day starting index and ending index are variable values and depend on the same character '/' to determine its start and end. How might I differentiate the first '/ ' from the last '/'?

If you are just trying to convert the date then follow Gary's students advice or the plethora of other answers on how to convert a date from TEXT to a DATE or a date from this format to that format.

If you are truly looking for any example of retrieving the text between the first two sets of identical numbers, you could use a formula such as

=MID(A1,FIND("/",A1)+1,FIND("/",A1,FIND("/",A1)+1)-FIND("/",A1)-1)

POC

With text in A1 , in another cell enter:

=DATEVALUE(MID(A1,FIND(" ",A1)+1,99))

在此处输入图片说明

Explanation:

  1. we grab the part of the string after the space: 11/29/18
  2. DATEVALUE() changes this to a true Excel date.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM