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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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