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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete where timefield < getdate + 5 minutes

Status
Not open for further replies.

kss1133

Programmer
Mar 22, 2006
22
US
I'm haveing trouble with trying to delete records from a table where the datetime field is less that now +5 minutes.

Thanks for any help,
 
Less than now +5 or -5 minutes?

For -5:
Code:
delete from myTable
where myColumn < getdate() - '00:05:00'

------
[small]<this is sig>
select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')
</this is sig>[/small]
[banghead]
 
So you want to pretty much delete everything from your database? Or is the majority of your data in the future?

If GETDATE() = '2006-05-11 05:05:00 PM', then you want to delete everything before (less than) '2006-05-11 05:10:00 PM' correct?

-SQLBill

Posting advice: FAQ481-4875
 
I have a table in that table is a field activedts when activedts gets to be 5 minutes old I want to delete it.
 
Yes I would think that

delete tblunique
where datediff(mm,activedts ,getdate()) > 5

would work but it does not. The date in the field is '2006-05-11 15:06:00'
 
I think I found the issue.

delete tblunique
where datediff(mm,activedts ,getdate()) > 5

The mm needs to be changed to mi.

Thanks everyone.
 
I got it working I had to use mi in my datediff not mm.

It is working fine now. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top