Converting a text field into a Date Field

SherriKilgore

Registered User.
Local time
Today, 17:17
Joined
May 4, 2012
Messages
19
I have a text, date field I need to convert to a date field.

For example: 2/11/14 is stored at text: 21114.

How can I convert the 21114 into 2/11/14?
 
Uh oh. Is January 11, 2014 stored the same as November 1, 2014?
 
No November would be 110114 and January would be 10114.
 
Basically, what you'll need to do is use string manipulation to insert the slashes in the right space, and then it can be converted to a date with CDate.

Code:
CDate(Left(DateString, Len(DateString) - 4) & "/" & Mid(DateString, Len(DateString) - 3, 2) & "/" & Right(DateString, 2))

DateString is a string variable containing the string you're converting. You'll need to change that name to fit your code.
 

Users who are viewing this thread

Back
Top Bottom