Delete Query using date format

levi.rogers

New member
Local time
Today, 05:00
Joined
Mar 8, 2007
Messages
9
I would like to delete records using a sql statement and comparing dates.

The dates will be current date and creation date.

Creation date will be imported into the table from another database. Obviously the current date will be rendered by the system.

I would like to delete all records that have a created date less than 30 days old.


Any thoughts.
 
Why would u want it deleted if it is less than 30 days old? you mean greater than 30 days? i hope thats what u mean otherwise it would be pointless.

so try
DELETE "*" FROM [TableName] WHERE (([currentdate]-[createddate]) >30)
 
Actually that is exactly what I meant.

I am building a database to use for some larger mail merge applications. I would like to exclude (among other things) all accounts that have been opened within the last thirty days as they do not qualify for the offer we are mailing out.

I will let you know if that worked. Thank you for your time and your work.

LR
 
you sure u want to delete the records? why not just run a query to select the ones over 30 days old then run ur mailing off of that? deletng the records would make it so none of them could ever get to 30 days
 
Well, yes I'm sure.

I understand your apprehension, however, this database is simply a small database that we import data from a larger into, it does not need to be kept as it takes only minutes too import the data, build the tables and do what needs done.
 
Got ya! well that should work then just make sure u do < 30
 
I'm curious why this isn't working.

DELETE "*"
FROM before_deleteQuery
WHERE (("Current_Date"-before_deleteQuery.dateCreated)<30);



I am getting a data type mismatch error.
 
DELETE *
FROM before_deleteQuery
WHERE Date() - dateCreated < 30;
 

Users who are viewing this thread

Back
Top Bottom