Get SQL Records Modified in the Last Hour

Here are two ways to  retrieve SQL records modified in the last hour.  The first method uses a fraction of a julian date to return the last hour.  The second method uses the DateAdd function.  I prefer using the DateAdd method just because it is easier to read.

Select y.ModDate
from yourtable y
where y.ModDate > GetDate() – 0.04166

OR

Select y.ModDate
from yourtable y
where y.ModDate > DateAdd(minute, -60, getdate())

 

Comments are closed.