How can I parse a date from a string of text

I have a memo field that has notes and dates in it.  I want to parse the date from this field to run a report with.  The dates are in different positions depending on the amount of notes that goes with it
BHanson71Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shaun KlineLead Software EngineerCommented:
Your description of the issue is vague. If you provide a few examples, it would be helpful.
0
Rey Obrero (Capricorn1)Commented:
you can extract the date using vba codes.
is there only a single date in the memo field?

function getThedate(vMemo as string)
dim j as integer, varArr() as string
vararr=split(vMemo," ")

for j=0 to ubound(varArr)
     'check the format of the varArr(j)
     if Isdate(varArr(j)) then
        ' we found a date
        getTheDate=varArr(j)
        exit function
     end if
end function


next
0
Rey Obrero (Capricorn1)Commented:
oops, error there

function getThedate(vMemo as string)
dim j as integer, varArr() as string
vararr=split(vMemo," ")

for j=0 to ubound(varArr)
     'check the format of the varArr(j)
     if Isdate(varArr(j)) then
        ' we found a date
        getTheDate=varArr(j)
        exit function
     end if
next
end function
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

BHanson71Author Commented:
Ok.  So I have a field called [Material] and it contains notes.  Usually looks something like "material due 9/25/15, component due 10/16/15".  I want to parse the first date to use in query.  What I am ultimately trying to do is say "Ok, 9/25/15 is next week.  Here's what's do."  I used the instr function. ex: NewField: InStr(1,[Material],"/") and then I used the mid function. ex:DueDate: Mid([Material],[NewField]-2,8).

My problem is that the dates vary in length from 6 to 8 characters.  I was looking for an easier way to just grab the date.
0
BHanson71Author Commented:
Thank you Rey.  I'd like to be able to do this in a Query though.
0
Rey Obrero (Capricorn1)Commented:
try this query

select [memo], getThedate([memo])
from tablex

'edited function

function getThedate(vMemo as string)
dim j as integer, varArr() as string
vararr=split(vMemo," ")

for j=0 to ubound(varArr)
     'check the format of the varArr(j)
     varArr(j)=replace(varArr(j),",","")      'remove comma if any exists
     if Isdate(varArr(j)) then
        ' we found a date
        getTheDate=varArr(j)
        exit function
     end if
next
end function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PatHartmanCommented:
Might I suggest an application change?  DO NOT EMBED DATES IN STRINGS.  In addition to being a violation of first normal form, it is noting but trouble to process.  Add a separate column to the table.  Parse the memo fields once.  Update the dates and change the interface so you never have to do this again.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.