0

Hi,

I have the following data in a excel csv file:

Date,Time,TempOut
3/17/2011,00:30,73.3

However, if I load it using:

ExclConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
                                            "Data Source=" + dir + ";" +
                                            "Extended Properties=\"text;HDR=Yes;FMT=Delimited\"";

Then:

string Data = "SELECT * FROM [" + FileName + "]";
                OleDbDataAdapter dtadpt = new OleDbDataAdapter(Data, ExclConn);
                //Create table
                dtadpt.Fill(dt);

If I display,

dt.Rows[0][1].ToString()

It shows 12/30/1899 12:30 AM instead just 00:30.

Any solution to this?

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by abelLazm
0

It happens when format of your input doesn't match your system's default time format check that.

Edited by abelLazm: n/a

0
dt.Rows[0][1].ToString("hh:mm");

It said: 'No overload method takes 1 argument'.
So I tried this: dt.Rows[0][1] = String.Format("{0:hh:mm:ss}", dt.Rows[0][1].ToString()); However, it insist on typing the date together with the time...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.