Link to home
Start Free TrialLog in
Avatar of Gordon_Atherley
Gordon_Atherley

asked on

vb6 Using SQL 'Delete From' with a date

Experts please

In a vb6 app which draws data from an Access 2000 database, I want to delete all records that are 7 or more days old. The following deletes all records regardless of date. ActDate is a date/time field

    Dim dCutOff As Date
    dCutOff = DateAdd("d", -7, Date)
    sSQL = "DELETE FROM activity where ActDate" & " < " & "#" & dCutOff & "#;"
    Set rs = cn.Execute(sSQL, , adCmdText)

What's wrong, and what should be done to fix the problem, please

Gordon
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gordon_Atherley
Gordon_Atherley

ASKER

emoreau and Dabas

You diagnosed the problem and provided effective solutions which differed slightly in approach. Your responses were but 2 minutes apart. Splitting the points seemed the fairest way to go

Thank you both

Gordon