Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete multiple posts using DateDiff()

Status
Not open for further replies.

breemermatta

Programmer
Dec 3, 2003
4
0
0
SE
Hi,

I want to create a stored procedure that deletes none, one or multiple posts from a table if the date in the table is older then 10 minutes. how do I do this?

The table (Users) contains UserID, Username and loginDateTime.

I have tried this code:

DELETE FROM Users
WHERE (SELECT DATEDIFF(mi, loginDateTime, getdate()) AS mins FROM Users) > 10

Why doesn't it work?
 
Do not use subquery:

DELETE FROM Users
WHERE DATEDIFF(mi, loginDateTime, getdate()) > 10

Zhavic

---------------------------------------------------------------
In the 1960s you needed the power of two Comodore64s to get a rocket to the moon. Now you need a machine which is a vast number of times more powerful just to run the most popular GUI.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top