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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

749 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