Date format using pre-defined specification in Access?

G

Guest

When attempting to import a text file using a pre-defined Import
Specification file that contains a Date field, the resulting table does not
have the corresponding field is not of the type Date/Time and the data is
brought in as text.

Example: 02051998 should be brought in as 02/05/1948 but comes in exactly
the same as in the text file.

Thanks.
 
D

Dirk Goldgar

BruceK said:
When attempting to import a text file using a pre-defined Import
Specification file that contains a Date field, the resulting table
does not have the corresponding field is not of the type Date/Time
and the data is brought in as text.

Example: 02051998 should be brought in as 02/05/1948 but comes in
exactly the same as in the text file.

I don't think you can make Access recognize 02051988 as a date on
import. You will probably have to link to the text file using an import
spec that defines that as a text field, then use an append query to
transform the linked records and put them into your target table (which
you would already have defined).

In the query that pulls data from the linked text file, use a calculated
field that converts the mmddyyyy field into a date field; e.g.,

NewDate: CDate(Format([TextDate], "00/00/0000"))

Then stuff the calculated field into the target date field.
 
G

Guest

Thanks Dirk. That explains it all.

Dirk Goldgar said:
BruceK said:
When attempting to import a text file using a pre-defined Import
Specification file that contains a Date field, the resulting table
does not have the corresponding field is not of the type Date/Time
and the data is brought in as text.

Example: 02051998 should be brought in as 02/05/1948 but comes in
exactly the same as in the text file.

I don't think you can make Access recognize 02051988 as a date on
import. You will probably have to link to the text file using an import
spec that defines that as a text field, then use an append query to
transform the linked records and put them into your target table (which
you would already have defined).

In the query that pulls data from the linked text file, use a calculated
field that converts the mmddyyyy field into a date field; e.g.,

NewDate: CDate(Format([TextDate], "00/00/0000"))

Then stuff the calculated field into the target date field.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 

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