Solved

find a string pattern and then extract date from it

Posted on 2009-04-02
3
222 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
Comment Utility
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
Comment Utility
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
Comment Utility
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now