|
-
Nov 12th, 2001, 08:33 PM
#1
Database help needed
how can I delete records from a database(access) where the user specifies on the form through a textbox the number of days worth of data to leave like 7 days to leave only data created in th elast 7 days in the table?
-
Nov 12th, 2001, 08:39 PM
#2
PowerPoster
You'd need to have some sort of field in each record that has when the record was created, then use some simple DELETE SQL to remove all those that fall before Date - 7 days
-
Nov 12th, 2001, 08:44 PM
#3
To figure out what date was 7 days from the current date is easy.
VB Code:
Dim Today As Date
Dim LastWeek As Date
Today = Now
LastWeek = Today - 7
MsgBox Format(Today, "mm/dd/yyyy")
MsgBox Format(LastWeek, "mm/dd/yyyy")
-
Nov 12th, 2001, 08:53 PM
#4
in the database the fields are SiteID, URL,Date,Retaindays
date = the date it was entered
i'm extremly new to sql but learning
see chris I told you ya help me alot
-
Nov 12th, 2001, 08:57 PM
#5
PowerPoster
First things first, I suggest you rename the "Date" field to something else, like "RecordDate" because Date is a reserved word and I find it causes problems if you do that.
Example of some delete SQL...
VB Code:
DELETE FROM [[i]TableName[/i]] WHERE [RecordDate] < #" & DateAdd("d",-7,Date) & "#;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|