Anyone have some code to find a date inside a string

charliemopps

Registered User.
Local time
Today, 09:27
Joined
Feb 24, 2009
Messages
40
I have a bunch of memo fields and none have the same info in them. But in all theres a point in which the the memo states something like:

Incident date: 05/14/2010 9:32AM GMT
or
Last seen: 2010-05-14 17:45 Z

etc.
So the date format could be any format really. And where it is in the text is anyones guess.
I've been able to find the single line its on via VBA so I can get it cut down to what you see above.

Does anyone know of some code that is the ultimate date converter? That could parse though this text and figure out what date is in there? I really don't care about the GMT / Z code at the end and could strip it away. What I really want is the date and time.

Thanks ahead of time!
 
Use regular expressions (namespace required is Microsoft VBScript Regular Expressions 5.5).

Reduce the number of potential fields by, for example, looking for fields containing forward slashes or hyphens (based on your examples), then define your regular expressions to match the different formats you expect, then use a function match to each of these formats.

Regular expressions are very useful for this sort of thing, although creating them can be a fiddle.
 
I finally got it. There were only about 8 different formats they could come in so I finally just got 8 if/then statements together and made it work.
 

Users who are viewing this thread

Back
Top Bottom