Hi, I am getting string value in object let say "28/05/2010". While i am converting it in to DateTime it is throwing exception as :
String was not recognized as a valid DateTime.
The Code is:
object obj = ((Excel.Range)worksheet.Cells[iRowindex, colIndex_q17]).Value2;
Type type = obj.GetType();
string strDate3 = string.Empty;
double dbl = 0.0;
if (type == typeof(System.Double))
{
dbl = Convert.ToDouble(((Excel.Range)worksheet.Cells[iRowindex, colIndex_q17]).Value2);
strDate3 = DateTime.FromOADate(dbl).ToShortDateString();
}
else
{
DateTime dt = new DateTime().Date;
//////////dt = DateTime.Parse(Convert.ToString(obj));
**dt = Convert.ToDateTime(obj).Date;**
strDate3 = dt.ToShortDateString();
}
The double star "**" line gets exception.