View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
dpb dpb is offline
external usenet poster
 
Posts: 109
Default Find position of date in string

On 10/9/2019 2:01 PM, RG III wrote:

Const myStr = "The video shows that on 9/24/2019 the suspect entered
the store."

i = InStr(myStr, "/")
myPos = InStrRev(myStr, " ", i) + 1



I suppose that works. It appears to just find the first "/" character
in a string, is that right?


Yes...not a very robust solution unless it can be assured the search
string doesn't have other instances of slashes besides.

And BTW, I made a typo in my above message. The format of the
dates is "m/dd/yyyy" or "mm/dd/yyyy".


You still have more work to do with the above even in the given case
depending upon whether is one- or two-digit month so you've got to
search back for the whitespace character before the characters before
the first slash to get the actual beginning of the string, the second
line in the above.

I dunno VBA well enuf to know otomh--is there a regular expressions
version of text search besides just simple string pattern matching? If
so, would be way to go.

--