[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

find a string pattern and then extract date from it

Posted on 2009-04-02
3
Medium Priority
?
244 Views
Last Modified: 2013-11-25
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


0
Comment
Question by:manivineet
  • 2
3 Comments
 
LVL 4

Expert Comment

by:Avelan
ID: 24057143
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

0
 
LVL 4

Accepted Solution

by:
Avelan earned 2000 total points
ID: 24057148
Whoops, a couple mistakes there but i'm sure you caught them anyhow :P
MyStr = Split(str, " ")(0)
 
If IsDate(MyStr) Then
   MyDate = Date.Parse(MyStr)
   'Whatever else you need to do
Else
    'whatever
End If

Open in new window

0
 
LVL 9

Expert Comment

by:Deathrace
ID: 24057703
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question