INSERT into DB DateTime string

mysql

Solution

You need to use `STR_TO_DATE()`:

STR_TO_DATE('04/04/2012 04:03:35 AM', '%d/%m/%Y %r')

Or, better yet, present your literal in a format MySQL expects (e.g. `YYYY-MM-DD HH:mm`).

Problem

I have the string `04/04/2012 04:03:35 AM`. How can I convert it and insert into a table? Field type is `datetime`.

Original source

Related problems