Posted on 1998-08-18
Last Modified: 2010-08-05
I have a comma delimited text file with double quotation marks surrounding text.  Within each line is a field for dates but they are designated as text(,"01/01/1998",).  Ultimately I need to import these into Access but prior to this I modify the files using a VB program which reads, modifies, and outputs the data.  During this modification process, I have been using CDate() to convert the text date (,"01/01/1998",)into a date data type (,#1998-01-01#,) but when importing into Access, I get an error.  Is there another function or statement I should use to convert the text date into a date data type that Access will recognize?

Thanks in advance, showme

P.S. more points may be awarded pending difficulty
Question by:showme
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Expert Comment

ID: 1429535
When you use CDate()in vb are you using it like this?

Dim dl As String
 dl = "01/01/1998"

MsgBox (CDate(dl))  This will give you 1/1/98 as a date.  I don't see the problem.  If I am missing something let me know.



Expert Comment

ID: 1429536
I find that for these problems using the 01-JAN-1998 format gives the programs least chance to forget which country they are in.


Expert Comment

ID: 1429537
I am going to research this. In the meantime you should re-open this to other experts

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Expert Comment

ID: 1429538
I still am confused.  I pasted this #1998-01-01# into a querygrid, it still gives me 1/1/98 as a date.  when you import is your table set up as a date field?

Author Comment

ID: 1429539
Thank you for looking into this, I appreciate it.  By the way, try creating a text file an simply put #1998/01/01# (the result of using Cdate()on the text date)in it.  Next try importing it into Access specifying that the above date is a date/time data type.  This should produce the error that I am encountering.  Granted, this whole problem may disappear if I were to directly put the data into an Access table instead of outputting a modified text file and then importing into Access, but since I have the problem I may as well try to figure it out.

Thanks again, showme

Accepted Solution

SPECIALIST earned 50 total points
ID: 1429540
I tried your example and I see what your problem is.  In my view without extensive research your options are as follows.  If you are using visual basic to export to a text file use the MID function that I gave you earlier to export it without the #.

Then you can import it as a date/time field

your other option and probably easiest is to import to access as text and do a query on that and the querygrid would be like this.  Assume the date in the text file is #01/01/1998#

newfieldname:cdate(mid([fieldfromtable]2,10)) this will convert the text to a date format.  It is easy and problably what you want to do.


Author Comment

ID: 1429541
Thanks again for the help.  It seems rather odd that Access is unable to read date literals from a text file but them's the breaks I guess.

Regards, showme

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 12 hours left to enroll

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question