BEST: yyyy-mm-dd or yyyy/mm/dd These are UNAMBIGUOUS. Can confidently be converted via CDate or DateValue functions.
The other NUMERIC forms are mm-dd-yyyy or dd-mm-yyyy. The CONVERSION of either of these can be problimatic. It is best to MAP the year, month and day values into the DateSerial function using the MID function.
Date formats that contain TEXT have special challenges.
Skip,
Have you heard that the roundest knight at King Arthur's round table was... Sir Cumference!
Thanks. The data always comes in like this: mm/dd/yyyy -- there is always 2 digits on the month and day, so that part is good. So far, all I've had to do is change the data type of the field to Date/Time in Table Design View of the table and all is well. (I haven't seen any bogus dates yet.) But I would like to progammatically change the data type of the field in the table with VBA right after the import is finished. I will play with the DateSerial function and see how it goes. I've used MID before. Any other suggestions are greatly appreciated.
...and it worked. I still don't know how to programmatically change a field's data type using VBA, but I can base the rest of what I want to do in the Access database off the query with the calculated field CalcDate that changes the date text into true date data... so this works.
If I was manually importing the table, yes, I could adjust the data types as I go, but I need to keep this process automated. Right now the import happens through a macro TransferDatabase action which works slick -- no user interaction required. I just need a programmatic -- VBA -- way to change a field's data type after the table and data is already established in the database. Is this even possible through VBA? I don't think that question has been directly answered. Thanks.
Skip, There is no manual decision here. I already know what field I need to convert. The trick is only how to convert a field to a new data type programmatically.
pbaldy - I think that's exactly what I was looking for. Thanks.
But see my earlier posting -- "Right now the import happens through a macro TransferDatabase action which works slick -- no user interaction required." But this import process provides no options for modification.
If you were to MANUALLY perform, ONE TIME, the import, with the appropriate date conversions, and SAVE the import specification, then you could use that Import Spec in your "slick" (however, imperfect, in need of post processing, not too slick in my book) macro, NO USER INTERACTION REQUIRED!!!
Skip,
Have you heard that the roundest knight at King Arthur's round table was... Sir Cumference!
ok, I'm with you, but I do not konw how to save an import specification under menu system when importing objects from one Access database to another (File|Get External Data|Import). In this case the Import Wizard doesn't start (which is where I believe I've seen the option to save the import spec before). Thanks.
Skip, Thanks, but see my two earlier postings -- I'm "from one Access database to another (File|Get External Data|Import)." Importing a table from one Access database to another does not start the wizard which does not allow me to save the import specification. Your idea had merit, but it just doesn't work with the type of import I'm doing. Enough please!
Correct me if I'm wrong, but the [blue]TransferText[/blue] method is the only one having the [blue]SpecificationName[/blue] parameter! . . . [blue]Micah68[/blue] is using [blue]Transferdatabase[/blue].
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.