c# - Filling data from an oracle table is not taking date and time -
i trying fill datatable data oracle table. while fetching data uses oracle connection, , oracle data adapter in c# fill data table. actual oracle table has column datatype date .this column has both date , time in format "10/26/2006 3:52:18 pm' ,but when filled datatable takes date .please help
here code ,
string oquery = "select * table_name insert_date between to_date ('" + startdate[i] + "', 'yyyy-mm-dd') , to_date ('" + enddaterr[i] + "', 'yyyy-mm-dd') ";
oraclecommand cmd = new oraclecommand(oquery, con); oracledataadapter oda = new oracledataadapter(cmd); datatable dtb = new datatable(); oda.fill(dtb);
have tried casting date in c#
datetime.now.tostring("mm/dd/yyyy hh:mm:ss tt")
and when retrieving oracle cast back, using oracle format
select to_char(sysdate,'mm/dd/yyyy hh:mi:ss am') dual
using (oracledatareader dr = zurich.common.oracledataaccess.executereader(cn, commandtype.text, mysql)) { if (dr.hasrows) // file exists in db { while (dr.read()) { currentdays = convert.toint16(((datetime.now.adddays(-1).date) - convert.todatetime(dr[0])).totaldays); console.writeline(checkdate(convert.todatetime(dr[0]))); lbbugs.items.add(string.format("{0:dd/m/yyyy h:mm:ss}", dr[0]) + ": " + dr.getstring(1) + " : " + currentdays);
Comments
Post a Comment