June 6, 2008 at 4:04 am
How do I select records that were inserted 30 minutes ago in a table.
June 6, 2008 at 4:26 am
If you are storing the date and time of insertion in a column, you can use following query:
select * from TableName where ColumnName >= dateadd(mi, -30, getdate())
June 6, 2008 at 5:07 am
If you store datetime column, can do as follow as well
select * from TableName
where datediff(mi, getdate(), Columname) <= 30
June 6, 2008 at 8:30 am
If the datetime column is indexed, then Suresh's solution would probably give you better performance. It should allow for index seeks, whereas Telammica's will likely result in index scans.
Either would return the correct result though.
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
June 6, 2008 at 11:42 am
If you don't have such "timestamp" column you are probably out of luck 😉
* Noel
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply