How to change script to delete record after on year.

C

chug

How do I change this script to delete records after they are one year
old?

RSa.MoveNext
Loop

set fso = Nothing
RSa.Close

' Then, Delete old notifications

sql = "DELETE FROM residential WHERE enddate < #" &
DateAdd("d",-365,NOW()) & "#"
RSa.Open sql, "DSN=Auction"

sql = "DELETE FROM residential WHERE enddate < #" &
DateAdd("d",-365,NOW()) & "#"
RSa.Open sql, "DSN=Auction"

sql = "SELECT * FROM residential WHERE 1 = 1"
if Request("NewHomes") <> "" then
sql = sql & " AND NewHome = 1"
end if
if Request("Foreclosure") <> "" then
sql = sql & " AND Foreclosure = 1"
end if
sql = sql & " ORDER BY ViewingDate DESC"

On Error Resume Next
RS.Open sql, "DSN=Auction"
If err.number <> 0 Then

Response.Write err.description & "<br>"
Response.Write sql
Else%>
 
E

Evertjan.

chug wrote on 28 okt 2005 in microsoft.public.inetserver.asp.general:
sql = "DELETE FROM residential WHERE enddate < #" &
DateAdd("d",-365,NOW()) & "#"

sql = "DELETE FROM residential WHERE enddate < #" &
DateAdd("yyyy",-1,NOW) & "#"

Perhaps. depending on your engine, also:

sql = "DELETE FROM residential WHERE enddate <
DateAdd("yyyy",-1,NOW)"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top