Importing a file with dates

G

Guest

I have to import into my database a comma-delimited file containing lots of
dates. The dates are all in YYYYMMDD format. Since I will have to run lots of
queries on the resulting table where I have to do date comparisons, I'd like
to import all these dates as date columns. How can I do this in the quickest
way? At the moment, I am using TRANSFERTEXT to import the file but it leaves
the dates as text columns thus I cannot do any date comparisons on them.
 
V

Van T. Dinh

The first way is as I advised before: create an Import Spec manually (which
you can use in code) so the Access recognise the "Column" in the CSV is of
Date value and import it as date

If you want to use your exising method then, after import, create a new
Field "ActualDate" of Date data type and do an Update Query like:

UPDATE [YourTable]
SET [ActualDate] = DateSerial(CInt(Left([DateText], 4)),
CInt( Mid([DateText], 5, 2)) , CInt( Right([DateText], 2)) )
 

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