Solved

Dates

Posted on 1998-08-18
7
181 Views
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
0
Comment
Question by:showme
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:SPECIALIST
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.


SPECIALIST



0
 
LVL 2

Expert Comment

by:chris_a
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.

0
 
LVL 3

Expert Comment

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

Specialist
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 3

Expert Comment

by:SPECIALIST
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?
0
 

Author Comment

by:showme
ID: 1429539
Specialist,
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
0
 
LVL 3

Accepted Solution

by:
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.


Specialist
0
 

Author Comment

by:showme
ID: 1429541
Specialist,
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
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now