Importing a file with dates

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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)) )
 
Back
Top