thursdaysgeek thursdaysgeek - 1 year ago 76
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)

Answer Source

For SQL Server:

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


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download