Jump to content

How can I delete records based on a date field in character format


Recommended Posts

Perhaps someone with more experience can help this novice understand how to write a mySQL query to delete records older than a given day.

 

The table I have been given has has a field named LogDate with dates stored in a 19 character field

format as: yyyy-mm-dd hh:mm:ss

 

What I need to do is delete all records older a given archival day which is also in the character format: yyyy-mm-dd

 

No doubt this would be simpler if the dates were in a normal mySQL date field but alas that's not what life handed me.

 

Thanks for suggestions on how to write this query.

Mike

 

 

 

Thanks for helping this novice get pointed in the right direction.  The INTERVAL key word sounds like what I needed.  This will be the third query I've written in mySQL.  No doubt the nuances of mySQL versions are a big part of what separates experts from a newbee like me.  Next time I'll include the mySQL version I'm using - assuming I can find it.  Any other rules I violated?  Really appreciate the suggestion.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.