records inserted 30 minutes ago

  • How do I select records that were inserted 30 minutes ago in a table.

  • 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())

  • If you store datetime column, can do as follow as well

    select * from TableName

    where datediff(mi, getdate(), Columname) <= 30

  • 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?

  • 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