Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Select date from UI and on button click data will be deleted which will be two months prior date data than selected date.
Posted
Comments
King Fisher 3-Apr-14 7:55am    
have you googled it? what have you tried?

Do you really want to delete data from database? What gone is forever gone, no recycle bin. Read this: should-we-ever-delete-data-in-a-database[^]
Another reason to keep could be for audit purpose.
 
Share this answer
 
v3
This will be like this, if you have table called UserInfo with column RegistrationDate. Consider 'RegistrationDate' as datetime column. Now suppose it has data for range Jan 1st 2014 to March 31st 2014.

Now if user select 1st March , the data older then 2 months from 1st March will be deleted by below query
SQL
Delete from UserInfo Where RegistrationDate <= dateadd(month, -2, getdate())
 
Share this answer
 
Comments
Member 9459076 14-Apr-14 8:17am    
Thanks...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900