Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing the Data Type of a field from within a query 1

Status
Not open for further replies.

Nilo

MIS
Jan 30, 2002
21
US
I don't know the best angle to take on this....
I have a txt file that I import into an Access database.
One of the fields is a date field, but the format is YYYYMMDD, so it's not exactly what Access considers a date format. So I import the file using the Fixed Width method and place the field breaks so I isolate each part of the date. Year Field is YYYY, Month field is MM, and the Day field is DD. So once I have these date parts in their own fields within an Access Table, I concatenate them back together in the MM/DD/YYYY format in a query. Here's the problem, the data type of the new concatenated field is being treated like Text, which i guess it is at this point. Is there some way to change the data type of this "date" field to a Date/Time data type from with a query?
Also, if anyone knows of a better method of getting from point A (that being the text file) to point B (the final destination table in Access with the properly formatted Date Field, YYYYMMDD to MM\DD\YYYY) I would love to know.
Please let me know if anything in this post needs any clarification... Thanks
 
Something like this ?
CDate(YYYY & '-' & MM & '-' & DD)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top