Changing field type to 'date/time' using code

  • Thread starter Thread starter Naz Virani
  • Start date Start date
N

Naz Virani

I am importing .csv files into Access. The files contain
date fields that Access recognizes as date fields, but
fails to convert them successfully. When the fields are
imported as 'text', no errors are generated; however, I
have to set the field type to date/time in Access after
import, which I am doing manually.

Is there a code that I can use to change the text field
type to date/time? There are several files being imported
and I would like to automate this process.

Thanks
 
The easiest approach is to mimic what Access does behind the scenes when you
make the change through the GUI:

1) Add a new Date field
2) Run an Update query to transfer the values to that new Date field
3) Delete the old Text field.
 
Thanks for the reply. I discovered that the Alter Table
Alter Column statement accomplishes this.
 
Back
Top