Solved

find a string pattern and then extract date from it

Posted on 2009-04-02
3
233 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

724 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