I am importing an Excel file into SQL server. My date column is not exactly imported as it is in Excel. The time is changed. For example, '2015-08-11 6:44:31 PM' from Excel '11-Aug-2015 06:43:12 PM' to SQL (please ignore format, I changed it)
Why the time is changed?
I'm not getting desired results where I compare datetime with DB to avoid duplicates while import. Here is the that part of code:
if (cell != null)
{
if (cell.ColumnIndex == 0)
{
double d = double.Parse(cell.Text);
conv = DateTime.FromOADate(d);
DataTable dtx = DBConn.getDataTable("Select * from MyTable where DDate = '" + conv + "'");
if (dtx.Rows.Count > 0)
{
ForceContinue = true;
break;
}
else
{
newRecordCount++; //new record count ^
}
Temp1 = Temp1.Replace("<DDate>", conv.ToString("yyyy-MM-dd hh:mm:ss tt"));
}
}