BTW, HDR=Yes means the first row is the header and will be excluded. HDR=No means there is no header row and the first row should be treated as data.
Main Topics
Browse All TopicsDear All
I am having to write a Windows Service that picks up and processes csv text files.
I have no control over the format of the text files.
The first column of the text file is a date field which is stored in yy/mm/dd format. When imported into a data table using the Microsoft.Jet.OLEDB.4.0 data provider, the date is treated as invalid and therefore returns 30/12/1899 00:00:00. This is basically because its expecting dd/mm/yy.
Is there a way of temporarily altering this behaviour so that the system recognises yy/mm/dd dates.
Maybe you can recommend an alternative method of importing the data into a datatable that will give me more control.
Any help would be most appreciated.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi MoreHeroic
Yes, I am using the extended properties you suggest. The field does come through as datetime.
I am actually looking into just formating the data at the Select point so that it comes in as a string so I can manipulate it through code. Any idea on the Format(Date,????) command I need to use.
Sorry - im new to this!
I just tried this on a text file with dates entered 'backwards' and saw a similar result. For the desired date of 16/02/08 I put 08/02/16 in the text file and got 08/02/2016 00:00:00 in the datatable.
A 'dirty' fix though... Can't you just iterate through each row of the datatable after you've filled it, split the date into it's component parts and then rebuild the date string to the desired format. Then you can just write each corrected date back into the datatable.
Hi David
I can't iterate through the table as the values contained within bear no relation to the source file. VB basically sets the field to the default date format.
The files contain sensitive data but you can easily create your own. The format is similar to this:
00/01/03,19778,Andrew,John
00/01/07,21331,Simon Kerns
I do think reformatting when issuing the Select SQL statement it the best option although im unsure of the command I need.
I see what you're saying, but I didn't explain my solution so well...
What I meant was, fill your datatable with the data from the text file (albeit incorrectly formatted) . Once you've populated your datatable, you can dispose of the text file and then iterate through each row in the datatable, correcting the date entries row by row using some simple string manipulation.
You might try something like CONVERT(datetime, badfieldname, 11) AS convertedDate I'm not sure if that works with JET, I'm mostly a SQL Server guy. ( http://msdn.microsoft.com/
Business Accounts
Answer for Membership
by: MoreHeroicPosted on 2008-09-25 at 07:38:11ID: 22569646
Are you setting the extended properties on your connection string? Something like Extended Properties='text;FMT=Delim ited;HDR=Y ES'
Anyway, when you get the data into a recordset from the initial select does that column initially look like a date or a string? You may need to add a calculated column to your select query so that the date is parsed and then cast to date correctly.