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

Deleting records that are 2 months old

Status
Not open for further replies.

bjr149

Programmer
Jul 18, 2005
26
US
I have a table full of records with a datetime variable. I want to do maintenance on the table, and delete reocrds from that table that are 2 months old. i want to compare the field with the time the record was written
(eg. 3/20/2006 7:56:29 AM), to the current time if its more than 2 months old i want to delete the record. Thanks for the suggestions
 
delete from blah
where datecolumn < dateadd(mm, -2, getdate())

------
[small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top