This topic is locked
[SOLVED]

 How To Automatically Delete Record 3 months old

2/6/2014 10:11:17 PM
ASPRunnerPro General questions
G
gonzalosb author

Hi all,

i need to delete records dated more than 3 months when list page is refresh or open without the need of hit DELETE button.

Sergey Kornilov admin 2/7/2014

Use some code in List page: BeforeProcess event i.e.

CustomQuery("delete from MyTable where DateCreated<...")


Details depend on what database do you use. Example for SQL Server

CustomQuery("delete from MyTable where DateCreated<SELECT DATEADD(month, -3, getdate())")
G
gonzalosb author 2/14/2014

thank you. this code works perfect!!!

CustomQuery("delete from MyTable where DateCreated<Date()-90")


DateCreated is the column where the actual date is hold and 90 means that all record older than 90 days will be deleted.