Date conversion for my table

C

Clay

I have a table that we import data into from a text
file. Our dates in the text file are in a format like
20010101, etc.

Is there a way to make Access read and treat this as a
date?

20010101 = Jan. 1, 2001
20041212 = Dec. 12, 2004

Thank you in advance.
Clay
 
T

Tim Ferguson

Is there a way to make Access read and treat this as a
date?

20010101 = Jan. 1, 2001
20041212 = Dec. 12, 2004

SELECT DateSerial(CInt(Mid(DateString,1,4)),
CInt(Mid(DateString,5,2)),
CInt(Mid(DateString,7,2))) AS NewDateValue,
OtherField,
OtherOtherField,
etc
FROM ForeignTable IN "H:\imported\somedata.txt"

or something like that. It is often easier to import the stuff whole into a
temp table, and then do the conversions and cleaning within the database.

Hope it helps


Tim F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top