Jump to content

Need Date Comparison and delete record query


alan93

Recommended Posts

I would change the field to a 'date' data type rather than varchar(16).  Try this code out:

 

select * from table_name WHERE date_column <= CURDATE()

or

select * from table WHERE date_column >= CURDATE() 

 

In your case you would use Delete but try the Select first to make sure that it returns the records you need.

I have a date field in records that is formatted as such:

 

1/1/2009

 

or

 

4/5/2007

 

This field that holds these values is a varchar(16)

 

I need to delete all records that has a date older than todays date.

How do I do that?

 

Good luck doing it with VARCHAR. Shoudla done with a date type column.

I didn't know you could change the type after the column was populated. I guess I could try that.

Hope it doesn't break anything.

 

[

quote author=ainoy31 link=topic=220469.msg1011351#msg1011351 date=1223666580]

I would change the field to a 'date' data type rather than varchar(16).  Try this code out:

 

select * from table_name WHERE date_column <= CURDATE()

or

select * from table WHERE date_column >= CURDATE() 

 

In your case you would use Delete but try the Select first to make sure that it returns the records you need.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.