Home All Groups Group Topic Archive Search About
Author
20 Oct 2005 8:26 PM
J1C
How could I return all records in the last that were entered in a
single table in the last 10 minutes? One of the columns is datetime ...

Author
20 Oct 2005 8:34 PM
Aaron Bertrand [SQL Server MVP]
SELECT <column_list>
        FROM <tablename>
        WHERE <datetime_column> >= DATEDIFF(MINUTE, -10, CURRENT_TIMESTAMP)


Show quote
"J1C" <just1co***@yahoo.ca> wrote in message
news:1129840012.172371.203250@o13g2000cwo.googlegroups.com...
> How could I return all records in the last that were entered in a
> single table in the last 10 minutes? One of the columns is datetime ...
>
Author
20 Oct 2005 8:37 PM
J1C
Thanks ;) Right after I posted it I figured it out ..

select getdate() as 'now', dateadd(minute, -10, getdate()) as 'date
minus 10'
Author
20 Oct 2005 8:46 PM
Aaron Bertrand [SQL Server MVP]
>        WHERE <datetime_column> >= DATEDIFF(MINUTE, -10, CURRENT_TIMESTAMP)

Whoops, don't know my dateadds from my datediffs today.  That's the second
time I've transposed those in as many hours...
Author
21 Oct 2005 1:34 PM
J1C
No problem - I got it figured out. Thanks for the help!
Author
20 Oct 2005 8:36 PM
David Portas
SELECT *
FROM your_table
WHERE dt > DATEADD(MINUTE, -10, CURRENT_TIMESTAMP) ;

--
David Portas
SQL Server MVP
--

Show quote
"J1C" <just1co***@yahoo.ca> wrote in message
news:1129840012.172371.203250@o13g2000cwo.googlegroups.com...
> How could I return all records in the last that were entered in a
> single table in the last 10 minutes? One of the columns is datetime ...
>

AddThis Social Bookmark Button