How can I compare only the time portion of a DateTime data type in SQL Server 2005. For example, I want to get all records in which 'MyDate' field is after a specific time. The following example is a very long and probably not fast way of doing this. I want all date in wich time is greater than 12:30:50.400
SELECT *
FROM Table1
WHERE ((DATEPART(hour, MyDateField) = 12) AND (DATEPART(minute, MyDateField) = 30) AND (DATEPART(second, MyDateField) = 50) AND (DATEPART(millisecond, MyDateField) > 400))
OR ((DATEPART(hour, MyDateField) = 12) AND (DATEPART(minute, MyDateField) = 30) AND (DATEPART(second, MyDateField) > 50))
OR ((DATEPART(hour, MyDateField) = 12) AND (DATEPART(minute, MyDateField) > 30))
OR ((DATEPART(hour, MyDateField) > 12))