Canvert Date to Mysql Format

Hi guys,
Now I do confess to being a bit lazy here.
I have a database where dates are stored in a varchar fields (not sure why). They are created using
$date = date(“F j, Y, g:i a”); // May 31, 2006, 5:16 pm and then written to the varchar field in a MYSQL database.
I guess 2006 I was probably learning PHP.
My plan is to define a new date field of type date in mysql and then run a script to copy the dates from this old text field, convert to MYSLQ format and thn put them in the new field then delete the old text field.
I am hopeful some cluey coder will be be able to give me a few lines of tricky code to make the conversion. Thanks,
Frank

You can populate the new date column in ONE update query using the MySql STR_TO_DATE() function - MySQL :: MySQL 8.0 Reference Manual :: 12.7 Date and Time Functions

Sponsor our Newsletter | Privacy Policy | Terms of Service