How to find and store 4-digits in a string

I have a Table with 2 fields of different data types:  Location (Text), Date (Date).
Currently, the Date field is empty.
Is there a way to populate the Date field with the 4 numbers contained in the Location field and concatenate "1/1/" before 4 numbers.
The 4 numbers always appear adjacent and can be anywhere within the Location field.
See current state (BEFORE) and desired state (AFTER), below.


BEFORE:

ID    Location                                                                                            Date
1      c:\red\white\blue\red1844\green\snack1.doc
2      c:\yellow\green\wheat2015.bmp
3      c:\gr1995een\orange.jpg


AFTER:

ID    Location                                                                                            Date
1      c:\red\white\blue\red1844\green\snack1.doc                           1/1/1844
2      c:\yellow\green\wheat2015.bmp                                                 1/1/2015
3      c:\gr1995een\orange.jpg                                                               1/1/1995
clock1Asked:
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.

aikimarkCommented:
This should come close
Function Q_28713755(parmString)
    Static oRE As Object
    Dim oMatches As Object
    
    If oRE Is Nothing Then
        Set oRE = CreateObject("vbscript.regexp")
        oRE.Global = False
        oRE.Pattern = "\d{4}"
    End If

    If IsNull(parmString) Then
        Q_28713755 = Null
        Exit Function
    End If

    If oRE.test(parmString) Then
        Set oMatches = oRE.Execute(parmString)
        Q_28713755 = DateSerial(oMatches(0), 1, 1)
    Else
        Q_28713755 = Null
    End If

End Function

Open in new window


Update Mytable
Set [Date] = Q_28713755([Location])
Where  [Date] Is Not Null

Open in new window

0
clock1Author Commented:
Thanks for comment, but chose vb script in error.
0
Bill PrewCommented:
Inside the function body, the two lines that have "q =" in them need to be "Q_28713755 =".

Then create that function in the access db, and run the update query.

~bp
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
aikimarkCommented:
Thanks, Bill.

I have updated the code.
0
clock1Author Commented:
Thanks
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.