Failed to compare Time portion of DateTime when read database

  • Thread starter Thread starter muntyanu
  • Start date Start date
M

muntyanu

Hi all,
I have datetime field in database. When I am getting records older than
specific date that I passed in parameter I can not get records that
differs only in Time part of the datetime value.
Looks like comparison of Time portion in query failed.

I would appreciate any advice

Thanks,
Roman
 
Roman,

Can you show how you are making the comparison? It's a little vague
from your description. Some code would help.
 
Nicholas, thank you for quick reply,

I am using ADO OleDbCommand and in Visual Studio QuickWatch clearly can
see that the record that am going to get is older than datetime in
TimestampParam by 10 sec (for example). If I substract 1 day from the
database field value I am getting the record. It is definetly time
part comparison failed.

myCommand.CommantText = SELECT [NetLog].* FROM [NetLog] WHERE
Timestamp < @TimestampParam
 
extracted some lines from my code to show how I am reading database

OleDbDataAdapter adapter = new OleDbDataAdapter();
myCommand.CommantText = "SELECT [NetLog].* FROM [NetLog] WHERE
Timestamp < TimestampParam"
adapter.SelectCommand = myCommand;
System.Data.DataSet dataSet = new System.Data.DataSet();
int iNumRows = adapter.Fill( dataSet );

Thanks
 
Back
Top