I need a SQL statement to delete row that are older than 30 days.
My table events
has a field date
that contains the date and the time it was inserted in the database.
Will this work?
SELECT * from Results WHERE [Date] >= DATEADD(d, -30, getdate())
Use DATEADD in your WHERE clause:
...
WHERE date < DATEADD(day, -30, GETDATE())
You can also use abbreviation d
or dd
instead of day
.