thursdaysgeek thursdaysgeek - 3 months ago 10
SQL Question

How to get records after a certain time using SQL datetime field

If I have a datetime field, how do I get just records created later than a certain time, ignoring the date altogether?

It's a logging table, it tells when people are connecting and doing something in our application. I want to find out how often people are on later than 5pm.

(Sorry - it is SQL Server. But this could be useful for other people for other databases)


For SQL Server:

select * from myTable where datepart(hh, myDateField) > 17