Opening .CSV file from VBA mis-converts SOME dates - how to work-around 
Author Message
 Opening .CSV file from VBA mis-converts SOME dates - how to work-around

When System date is DD/MM/YYYY and a csv file is opened in Excel VBA, dates
in dd/mm/yyyy format and DD<=12 are incorrectly interpreted as American
dates, and converted to MM/DD/YYYY.  This doesn't happen if the CSV file is
opened directly in Excel.

So 12/11/2000 is interpreted as 11 Dec, 14/11/2000 is correctly interpreted
as 14 Nov

Has anyone else experienced this problem (unbelievable if not) but American
guys I guess unlikely! <g>

Does anyone know of any MSDN Q number, of MSDN knowledgebase reference,?

Does anyone have a workaround?

Greg (Oz, Sydney)



Mon, 05 May 2003 03:00:00 GMT  
 Opening .CSV file from VBA mis-converts SOME dates - how to work-around
Hi LaoGui,

I just read a thread in one of the .DATA newsgroups where someone said the
Text ODBC driver (which is what you'd probably be working with via VBA) only
works with dates in US format; I assume Excel performs some kind of
conversion when you work through its interface...

Quote:
> When System date is DD/MM/YYYY and a csv file is opened in Excel VBA, dates
> in dd/mm/yyyy format and DD<=12 are incorrectly interpreted as American
> dates, and converted to MM/DD/YYYY.  This doesn't happen if the CSV file is
> opened directly in Excel.

> So 12/11/2000 is interpreted as 11 Dec, 14/11/2000 is correctly interpreted
> as 14 Nov

> Has anyone else experienced this problem (unbelievable if not) but American
> guys I guess unlikely! <g>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister
http://www.mvps.org/word
http://go.compuserve.com/MSOfficeForum

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)



Mon, 05 May 2003 03:00:00 GMT  
 Opening .CSV file from VBA mis-converts SOME dates - how to work-around


Quote:
>Does anyone have a workaround?

My method is open it as XXX.TXT
Set the number format of that columns as text when opening that TXT.
After open, change that column to approproate Date format
Then do a search and replace "/" to "/"

Regards.
--
"Reply-To" address is OK.



Mon, 05 May 2003 03:00:00 GMT  
 Opening .CSV file from VBA mis-converts SOME dates - how to work-around
Thank you...


Quote:
> Hi LaoGui,

> I just read a thread in one of the .DATA newsgroups where someone said the
> Text ODBC driver (which is what you'd probably be working with via VBA)
only
> works with dates in US format; I assume Excel performs some kind of
> conversion when you work through its interface...

> > When System date is DD/MM/YYYY and a csv file is opened in Excel VBA,
dates
> > in dd/mm/yyyy format and DD<=12 are incorrectly interpreted as American
> > dates, and converted to MM/DD/YYYY.  This doesn't happen if the CSV file
is
> > opened directly in Excel.

> > So 12/11/2000 is interpreted as 11 Dec, 14/11/2000 is correctly
interpreted
> > as 14 Nov

> > Has anyone else experienced this problem (unbelievable if not) but
American
> > guys I guess unlikely! <g>

> Cindy Meister
> INTER-Solutions, Switzerland
> http://homepage.swissonline.ch/cindymeister
> http://www.mvps.org/word
> http://go.compuserve.com/MSOfficeForum

> This reply is posted in the Newsgroup; please post any follow question or
> reply in the newsgroup and not by e-mail :-)



Mon, 12 May 2003 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Opening a File Open window for file selection in VBA

2. converting *xls to *.csv file format

3. Converting CSV files to Graph

4. Converting a CSV text file

5. Importing date and timne from csv file

6. VBA - Import Data from CSV File

7. VBA Transfer Text CSV - Cannot find file

8. Reading CSV Files in XL-VBA

9. opening a CSV file in Visio thru VB

10. ADODB to open CSV text file, APPEND FIELD

11. Help needed opening CSV file with Common Dialog Box

12. Opening CSV file of more than 256 columns using ADO

 

 
Powered by phpBB® Forum Software