Link to home
Start Free TrialLog in
Avatar of manivineet
manivineet

asked on

find a string pattern and then extract date from it

if have a array of strings.
some of them look like:

test1
test2

but others look like
"2006-06 (jun)"
"2006-07 (jul)"

now i want to extract the date part from these strings (only the one's which contain the date, e.g. 2006-06) and convert (only the strings which look like they have date in them)  them to a "date time" format and store them in another array as "date time" items

how do i do it?

how


Avatar of Avelan
Avelan

Hey,
this should work.
Other solution is to use regex to extract the date but i'm not too familiar with it
so... ;)

-Avelan
MyStr = Split(str, " ")(0)
 
If IsDate(str) Then
   MyDate = Date.Parse(str)
   'Whatever else you need to do
Else
    'whatever
End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Avelan
Avelan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial