ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date Formatting (https://www.excelbanter.com/excel-programming/346580-date-formatting.html)

Nigel

Date Formatting
 
Hi All

I have a CSV file with a column that contains a European date, say
11/03/2005 (11 March 2005). If I open this directly Excel displays the
date as expected e.g. 11/03/2005. Because of the processing I need to do
with other fields I rename the file, before opening to a .TXT file with....

Name "c:\test\audit.csv" As "c:\test\audit.txt"

I then open the text file using.......

Workbooks.OpenText Filename:="c:\test\audit.txt", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote,
_
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 2), Array(9, 2))

The date now shows as 03/11/2005 !! - how can I stop this ?


--
Cheers
Nigel





Nigel

Date Formatting
 
Ok guys, I have it I did not realise the second element in the array is the
xlColumnDataType - setting this to option 4 loads the date as required.

Sorry to trouble you

--
Cheers
Nigel



"Nigel" wrote in message
...
Hi All

I have a CSV file with a column that contains a European date, say
11/03/2005 (11 March 2005). If I open this directly Excel displays the
date as expected e.g. 11/03/2005. Because of the processing I need to do
with other fields I rename the file, before opening to a .TXT file

with....

Name "c:\test\audit.csv" As "c:\test\audit.txt"

I then open the text file using.......

Workbooks.OpenText Filename:="c:\test\audit.txt", Origin:=xlWindows _
, StartRow:=1, DataType:=xlDelimited,

TextQualifier:=xlDoubleQuote,
_
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False,
Comma:=True _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1),

Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 2), Array(9, 2))

The date now shows as 03/11/2005 !! - how can I stop this ?


--
Cheers
Nigel








All times are GMT +1. The time now is 11:43 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com