I have a DataTable xData which has a DateTime column with millisecond accuracy, I need to extract the rows which match an exact time with milliseconds but cannot get the syntax correct.
I've tried
DateTime dt = timeStampList[i];
string str = dt.ToString("yyyy-MM-dd HH:mm:ss.fff");
DataRow[] result = xData.Select("TimeStamp2 = " + str);
foreach (DataRow row in result)
{
Console.WriteLine("{0}, {1}", row[0], row[1]);
}
but
DataRow[] result = xData.Select("TimeStamp2 = " + str);
causes an error:
Syntax error: Missing operand after '16' operator.
I've searched but most of the examples only show how to select by date and not a full datetime with milliseconds.