If i have this in my Database in a column of VARCHAR
2006/12/28 18:35:10
can i convert it to date time in C# ? I attempted this?
int
result =DateTime.Compare((DateTime)ds2.Tables[0].Rows[0].ItemArray[1], (DateTime)ds2.Tables[0].Rows[1].ItemArray[1]);which basically is taking two values in that format and comparing them but i get a invalid cast exception. And importing them into SQL As datetime is not possible.
do i have to convert it to an int first? or strip out the "/" and the ":" ? is it even possible?
thanks in advance,
mcm
UseDateTime.TryParse.Yeah Man,
worked like a charm.
mcm
you can use
Convert.ToDateTime(string)
Convert.ToDateTime produced the same cast error as my other attempt. by TryParse worked.
yay
0 comments:
Post a Comment