How To Select Records X Minutes in Age



TODO:

Have you ever wanted to select records in a table that are a certain number of minutes in age?

 

SOLUTION:

 

select *
from mytable
where datecreated < (SELECT DATEADD(minute, -X, GETDATE()) )

 

 

NOTES:

In the example above replace X with the number of minutes in age.  i.e. to select records 30 minutes in age, replace X with 30, so it would be "datecreated < (SELECT DATEADD(minute, -30, GETDATE()) )"



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading