# Clear Data From a Table

It can be helpful to clear stale data from a table.

- Establish the length of time that data can reside in the table before being deleted. For example, you could establish that data more than 7 days old can be removed.

  This would involve a query with the following syntax:

  DELETE FROM #TABLE

  WHERE Timestamp < DateTime('now', '-7 days')

- This can also be accomplished by using a tag (e.g. @MinDateToKeep), which defines the number of days to store data. This enables you to set the minimum inspection date to keep via a tag (e.g. $Databases.FastDatabase.Results.DeleteOld.Parameters.MinDateToKeep).

  When using a tag, a parameter needs to be added to the Query Parameters, MinDateToKeep, with a DateTime data type. This would change the query syntax to the following:

  DELETE FROM #TABLE

  WHERE Timestamp < @MinDateToKeep