I have a column in datatable having dates with format dd/MM/yyyy HH:mm
. I fill the datatable using the code below which is common for more than 1 select statements so i cannot specify column and their datatype before filling the datatable. Any manipulation after filling the data is acceptable to me.
data_adapt = New OracleDataAdapter(query, OraConn)
dt = New DataTable
data_adapt.Fill(dt)
For paging i create a copy of the datatable using skip and take as below
dtLineupCopy = New DataTable
dtLineupCopy = dtLineup.AsEnumerable().Skip(startRows).Take(pageSize)).CopyToDataTable()
Now the issue is when I use Compute method it doesn't treat the column values as date type and returns some random date value from the column instead of minimum value.
Arvdate = dtLineupCopy.Compute("Min(Arrivaldate)", "")
Is there a way to convert the datatype for the column?
Also tried adding a new column of datetime type but it throws error System.FormatException: String was not recognized as a valid DateTime
dtLineupCopy.Columns.Add("ArvDate", getType(DateTime), "CONVERT(Arrivaldate, 'System.DateTime')")
Data in Arrivaldate column of dtLineupCopy.
22/09/2012 01:02
27/09/2012 17:01
1/10/2012 1:02
13/10/2012 07:26
14/10/2012 19:47
20/10/2012 00:00
20/10/2012 00:00