Find records produced in the last hour
If you want whole hours use the following...
--This Hour
SELECT *
FROM Whatever
WHERE myTime >= dateadd(hour, datediff(hour, 0, GETDATE()), 0)
--Last Hour
SELECT *
FROM Whatever
WHERE myTime < dateadd(hour, datediff(hour, 0, GETDATE()), 0) AND myTime >= dateadd(hour, datediff(hour, 0, DATEADD(HOUR, -1, GETDATE())), 0)
--Hour before last
SELECT *
FROM Whatever
WHERE myTime < dateadd(hour, datediff(hour, 0, DATEADD(HOUR, -1, GETDATE())), 0) AND myTime >= dateadd(hour, datediff(hour, 0, DATEADD(HOUR, -2, GETDATE())), 0)
Use this:
SELECT * FROM YourTable WHERE YourDateTime >= DATEADD(hh, -1, GETDATE())
Use this:
SELECT *
FROM Whatever
WHERE myTime > DATEADD(HOUR, -1, GETDATE())