If I have a string that represents the date and time such as ’30/09/2011 10:14′ which is a non-standard DATETIME format. Can I reformat this to a standard DATETIME format on insert into a DATETIME field in a MySQL database table?
I have tried this:
INSERT INTO test(lastdate) VALUES(DATE_FORMAT('30/09/2011 10:14', '%d/%m/%Y %H:%i'))
The result is NULL in the lastdate DATETIME field.
You can use
str_to_dateto convert for your insert :DATE_FORMATis for translating a date / time field to another format onselect