Solved

Dates

Posted on 1998-08-18
7
205 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
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…
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…

810 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