[AccessD] A2003: Extracting strings

Steve Erbach erbachs at gmail.com
Thu Nov 17 16:06:23 CST 2005


Dear Group,
 Lets say you have a note field in a table into which your users have been
entering text notes that include dates in various formats (9-1-05, 10/12/04,
8/3/2004, etc.) as well as the text. What I'd like to do is extract those
dates from the note field and stuff them into a bona fide date field.
 It's straightforward enough to locate, say, all the dates that have dashes
in them with a query like this:
 SELECT *
FROM tblNotes
WHERE ((Note Like "*##-##-##*")
OR (Note Like "*##-#-##*")
OR (Note Like "*#-##-##*")
OR (Note Like "*#-#-##*")
OR (Note Like "*##-##-####*")
OR (Note Like "*##-#-####*")
OR (Note) Like "*#-##-####*")
OR (Note Like "*#-#-####*"));

This gives me all the records that have dates formatted with dashes. But
what I want is to actually extract those dates and stuff them into a new
column as a Date type.
 I've looked through the Access 2003 Help for a while but I don't seem to
find anything that jumps out at me. To use the Instr() function you need to
supply a literal value, not a pattern. I guess what I'm looking for is a
function similar to the Match() function in the old Borland Paradox program.
You provided the string to search as well as the string pattern you're
searching for and the Match() function would stuff the located substring
into a variable for you.
 Anything like this that you can think of? I'm considering writing a VBA
Match() function, but I'm hoping there's something else available. Thanks.

Regards,

Steve Erbach
Scientific Marketing
Neenah, WI
www.swerbach.com <http://www.swerbach.com>
Security Page: www.swerbach.com/security <http://www.swerbach.com/security>



More information about the AccessD mailing list