How to change script to delete record after on year.

Discussion in 'ASP General' started by chug, Oct 28, 2005.

  1. chug

    chug Guest

    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%>


    *** Sent via Developersdex http://www.developersdex.com ***
     
    chug, Oct 28, 2005
    #1
    1. Advertising

  2. chug

    Evertjan. Guest

    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)"


    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Oct 28, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. J
    Replies:
    2
    Views:
    2,567
  2. Otuatail

    Week of year to full Year

    Otuatail, Dec 8, 2003, in forum: HTML
    Replies:
    4
    Views:
    987
    Toby A Inkster
    Dec 8, 2003
  3. André
    Replies:
    0
    Views:
    3,780
    André
    Jun 25, 2006
  4. André
    Replies:
    0
    Views:
    466
    André
    Jun 25, 2006
  5. Veerle
    Replies:
    2
    Views:
    429
    niceguy
    Aug 20, 2003
Loading...

Share This Page