how can I read date and time from ascii file?

  • Thread starter Thread starter Nazrul
  • Start date Start date
N

Nazrul

I have an ascii file to read date, time, data1 and data2
as shown below from EXCEL.
1999-10-25 00:00:00 0 0
1999-10-25 00:03:00 3.657 0
1999-10-25 00:06:09 3.657 26831.4

I can read data1 and data2 correctly, but not date and
time. Is there somebody who can help me out?

Nazrul
 
If you're using the Text wizard to bring the file in, on the third
pane, select the date column and choose YMD from the date dropdown.
I'm not sure what trouble you're having with time - what are you
seeing?
 
I am not using any text wizard to bring a file, rather I
use MACRO to read the file. For example,
***********************
Open outpath For Input As #2 ' outpath is the path and file
Input #2, pdate, ptime, data1, data2

***************************
Thank you
 
You could use something like:

Public Sub ImportTextFile()
Const csPATH As String = "<your path>"
Dim sFileName As String
sFileName = "Untitled.txt"
Workbooks.OpenText _
Filename:=csPATH & sFileName, _
DataType:=xlDelimited, _
TextQualifier:=xlTextQualifierDoubleQuote, _
ConsecutiveDelimiter:=True, _
Tab:=True, _
Space:=True, _
Comma:=False, _
Semicolon:=False, _
Other:=False, _
FieldInfo:=Array(Array(1, 5), Array(2, 1), _
Array(3, 1), Array(4, 1))
End Sub

Or record a macro of opening it the way I suggested.
 
Back
Top