Change Date Format on Import to MySQL from CSV File

September 2, 2015 (9 years ago)
Database

You have a .csv file with a date column that is formatted like this:  12/1/2015 (‘m/d/Y’).

You need to import it into a MySQL database DATE field named “my_dates”.

A straight import will result in all your dates showing up as ‘0000-00-00’, because MySQL uses the format ‘Y-m-d’, and won’t translate it natively.

Here’s the solution:

Create a VARCHAR field named “my_text_dates” in the database, and import the dates there.

Then, run this query:

Then, just delete the “my_text_dates” field, and you’re all set!

NOTE: the ‘%m/%d/%Y’ portion of the update statement needs to match exactly the format of your text date field.

Database Maintenance

October 17, 2014 (9 years ago)
Database, WordPress

WordPress automatically deletes items you have trashed (posts, pages, etc) after 30 days. You can set this to fewer days to keep them from building up.

Put this in your wp-config.php file:

 

Limiting Revisions

October 17, 2014 (9 years ago)
Database, WordPress

To keep your database from bloating with endless revisions, you can limit the number that’s stored for each post.

Put this in your config.php file. (The second parameter is the number of revisions to keep.)