I have a simple application which stores the data into the sql server database table named student table .The design of the table is as follows 3 colums. name ,sex and registeredtime(datetime).In my WPF window i have three fields to insert the data into the table.Now i want to have the delete button based on the input given by the user(which is a datetimepicker).
How to delete the data from the table which is 7 days old compared to the date given by the user. ?
I want to have a stored procedure which i can call from the c# code.i am able to try some thing like this but Select * from studenttable where registereddate < GetDate()-7 but i am unable to achieve what i am supposed to …
You will probably need to use the DATEADD function:
Make sure you do the equivalent select first to make sure you are deleting what you want:
Your stored proc would look something like this: