MySQL built-in functions are very important functions. We can use MySQL built-in functions to convert strings to dates. The following describes this method for your reference.
Use str_to_date) in mysql to convert a string to a date.
MySQL built-in function instance:
The separators are the same, and the year, month, and day must be the same.
- select str_to_date('02/25/1998 12:00:34 AM','%m/%d/%y %h:%i:%s %s') as column_name from table_name;
-
- str_to_date('08/09/2008', '%m/%d/%Y'); -- 2008-08-09
-
- str_to_date('08/09/08' , '%m/%d/%y'); -- 2008-08-09
-
- str_to_date('08.09.2008', '%m.%d.%Y'); -- 2008-08-09
-
- str_to_date('08:09:30', '%h:%i:%s'); -- 08:09:30
-
- str_to_date('08.09.2008 08:09:30', '%m.%d.%Y %h:%i:%s'); -- 2008-08-09 08:09:30
-
Difference between NULL and MySQL NULL strings
In-depth study of MySQL result strings
MySQL string truncation Function Method
MySQL string segmentation implementation
MySQL replaces the specified field string in batches