<vb********@yahoo.comwrote in message
news:6e**********************************@w7g2000h sa.googlegroups.com...
hello I run an sql which returns a datarow itemarray field of
system.datetime. the problem is the database
only stores the date, but the returned value includes a time of
12:00:00 AM. I do not want the time.
How can I get only the date returned, just as it is stored in the
database? thanks
reference - system.data.oracleclient
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OracleClient;
using System.Data;
OracleConnection oOracleConn = new OracleConnection(conn);
oOracleConn.Open();
OracleCommand cmd = oOracleConn.CreateCommand();
cmd.CommandText = sql;
cmd.CommandType = CommandType.Text;
OracleDataAdapter adapt = new OracleDataAdapter(cmd);
DataSet myDataSet = new DataSet();
myDataSet.Clear();
adapt.Fill(myDataSet);
You would have to use a stored proc on Oracle that would String Format the
date with a mask of ("mmddyyyy"), as and example, the way you wanted it
when it returned the result set. A stored proc in Oracle is the equivalent
to a stored procedure on MS SQL Server.
The other way you could do it is make a Accessor Object (AO) that represents
the fields of the dataset table fields in question and walk the table row
by row. On each row read, you populate corresponding fields to the AO.
However for the date field, you would use a ToString on the date field in
the table to populate the string date field in the AO. The ToString would
look like this -- ToString("mmddyyyy"), and then you add the AO to an
ArrayList which can be bound to a datasource of a DataGridView as an
example.
Or you could use the List <another form of an ArrayList.