hi,
I have DataRow that has a cell of type datetime, i've tried to convert the value to DateTime by (DateTime)row[7] and
Convert.ToDateTime(row[7]) but none of that works, why?
TY
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
naura paxPosted Nov 10, 2009, 3:31 AM
DateTime dt=new DateTime();
if(dr[7]["OrderDate"]!=DbNull.Value)
dt=Conver.ToDateTime(dr[7]["OrderDate"]);
try above (replace OrderDate with whatever column you have.
Nilanka DharmadasaPosted Nov 10, 2009, 3:59 AM
Sorry. From your question I understood something else.
I thought row is DataRow and 7 is the column index. Coz you have talked about a cell.
But accrording to the accepted answer, it seems 'row' is your row colloction.
Nilanka DharmadasaPosted Nov 10, 2009, 3:21 AM
Use this.
DateTime d=Convert.ToDateTime(row[7].ToString());