Original: MS SQL Server with time records how to query
For example, a table [a] has a save date containing the Time field [b], if the paragraph [b] as the query criteria to query data records. And we have to spend some time trying to find the records we want.
Now we need to query all records for 2014-06-21 of the day:
SELECT * from [A] WHERE [B] = ' 2014-06-21 '
The syntax above will not be queried for any records. Perhaps some netizens think of using between:
select * [ a [ b " 2014-06-21 00:00:00 Span style= "color: #ff0000;" > '
This specifies the date range, and you can actually query the data record for this day, but if [B] has a store for 2014-06-21 23:59:59. xxx Such time, this record will not be queried.
Perhaps you can use the following method to solve the "How to get the midnight time value of the current date" http://www.cnblogs.com/insus/archive/2011/09/09/2172419.html and "how to get the maximum time value for the current date" Http://www.cnblogs.com/insus/archive/2011/09/09/2172687.html
In this way, it can be written as:
But the implementation seems to be a bit more complicated, is it easier to spell it? Look: