trying to extract a date within a text field

  • Thread starter Thread starter Ed
  • Start date Start date
E

Ed

I have a text field in a table that is 40 characters.
Somewhere in the field a date will exist. I'd like to
extract the date and place it in another field. I know
the date will always be the two characters to the left of
a "/" character and two characters to the right of the "/"
character. Any suggestions would be appreciated.
 
I have a text field in a table that is 40 characters.
Somewhere in the field a date will exist. I'd like to
extract the date and place it in another field. I know
the date will always be the two characters to the left of
a "/" character and two characters to the right of the "/"
character. Any suggestions would be appreciated.

Do you mean the field data is like this:
"Sales for 03/04"

Exp:Mid([FieldName],InStr([FieldName],"/")-2),5)
 
Thanks very much
-----Original Message-----
I have a text field in a table that is 40 characters.
Somewhere in the field a date will exist. I'd like to
extract the date and place it in another field. I know
the date will always be the two characters to the left of
a "/" character and two characters to the right of the "/"
character. Any suggestions would be appreciated.

Do you mean the field data is like this:
"Sales for 03/04"

Exp:Mid([FieldName],InStr([FieldName],"/")-2),5)
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
.
 
Ed said:
I have a text field in a table that is 40 characters.
Somewhere in the field a date will exist. I'd like to
extract the date and place it in another field. I know
the date will always be the two characters to the left of
a "/" character and two characters to the right of the "/"
character. Any suggestions would be appreciated.

Test VBA would be:

Public Sub ExtractDate()

Dim MyString As String
Dim MyDate As String

MyString = "**/21**"

MyDate = Mid$(MyString, InStr(MyString, "/") + 1, 2)

Debug.Print MyDate

End Sub

User Defined Function:

Public Function ExtractDate(MyString As String) As String

ExtractDate = Mid$(MyString, InStr(MyString, "/") + 1, 2)

End Function
 
Back
Top