Use DATEDIFF and DATEADD to get datetime datetime instead. Compare the column only with the date, and it will return those rows that have non-zero time.
How it works, we first calculate the difference (in days) between the era and the value. We add this number in the era to create a new datetime. Since the result of DATEDIFF is an integer, any time component is rounded.
SELECT * FROM Table WHERE DateColumn <> DATEADD(d, DATEDIFF(d, 0, DateColumn), 0)
Then the time function can be implemented as follows, but I do not recommend it for this particular scenario:
SELECT DATEDIFF(minute, DATEADD(d, DATEDIFF(d, 0, DateColumn), 0), DateColumn) as MinutesIntoDay,
Edit: As mentioned in other answers, you can use DATE to achieve the same effect as DATEADD(d, DATEDIFF(d, 0, DateColumn), 0) , which clears well. However, DATE is only added in SQL Server 2008, while the formula is compatible with at least SQL 2000. Therefore, if you need backward compatibility or deal with SQL CE, casting in DATE is not available.
Mitch
source share