run delete query ?

  • Thread starter Thread starter _Bigred
  • Start date Start date
B

_Bigred

I would like to run a delete query that deletes all records that are older
then the date it is run

(e.g If I run the query on 03/05/06, any records that have a "endDATE" that
is older gets deleted.)

TIA,
_Bigred
 
_Bigred said:
I would like to run a delete query that deletes all records that are older then
the date it is run

(e.g If I run the query on 03/05/06, any records that have a "endDATE" that
is older gets deleted.)

DELETE * FROM TableName
WHERE endDate < Date()
 
Hello Rick ,

I used your example and it works great for the date. Is there any way I can
set a 2nd parameter so:

If record is older that todays date OR if it is has a Hour field that is 0
(zero)?

I am trying to avoid having to run 2 seperate delete queries to do this.

TIA,
_Bigred
 
If you mean that the hour of EndDate is from Midnight to 1 AM then this
would work.

DELETE * FROM TableName
WHERE endDate < Date()
Or Hour(EndDate) = 0

If you mean that EndDate has no time attached to it (it is exactly midnight)
then the following should work as long as EndDate is never null.
DELETE * FROM TableName
WHERE endDate < Date()
Or CLng(EndDate) = EndDate
 

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

Back
Top