>>>>DateTimes have always been problematic in searches if you don't treat them as strings. I will add this to that SO link.
>>
>>FWIW I've been querying DATETIME in SQL Server and Oracle for over 20 years. For datetime fields, initially a different string was assembled for each database matching a cast string value, until we realized that a datetime passed in a parameterized query via ODBC is automatically cast correctly AND uses the index on a datetime field, which casting to string often did not.
>>
>>My understanding is that datetime gets stored as 2 integers in SQL Server. Certainly it would be interesting to know what an index on that looks like.
>
>I don't think your searches was for exact matches. Otherwise you would know that by now. MS SQL server datetime is only have a sensitivity of 3 milliseconds.
>
>I don't understand what your comment "which casting to string often did not" means at all.
Did not use an index, that's how I understand it.
The index is probably on some form of bintoc(dayinteger)+bintoc(millisecondsinteger), but probably without any conversion - just take those 8 bytes as a string and it should sort correctly because it never contains negative numbers.