Solved

Dates

Posted on 1998-08-18
7
214 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
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.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Crystal reports - Formula Field code need assistance with code 17 81
How to make an ADE file by code? 11 94
MsgBox 4 68
VB 6 error 5 in windows 10 but not in XP 7 63
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

856 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