Important
New database features are no longer connected to engine versions; features are now enabled independently during scheduled update windows, and “major” and “minor” releases no longer exist in Helios. Please visit the release notes to view the latest features available in your database clusters.
STR_ TO_ DATE
On this page
The STR_ function extracts datetime value from input string according to a specified format.
Syntax
STR_TO_DATE (str, format)Arguments
-
str: a valid date, datetime, or time, formatted according to the specified format string
-
format: a string containing format symbols
See DATE_
Return Type
String
Examples
SELECT STR_TO_DATE('March 3rd, 2015', '%M %D, %Y');
+---------------------------------------------+
| STR_TO_DATE('March 3rd, 2015', '%M %D, %Y') |
+---------------------------------------------+
| 2015-03-03 |
+---------------------------------------------+SELECT STR_TO_DATE('2015-03-03 11:37:07', '%Y-%m-%d %h:%i:%s');
+---------------------------------------------------------+
| STR_TO_DATE('2015-03-03 11:37:07', '%Y-%m-%d %h:%i:%s') |
+---------------------------------------------------------+
| 2015-03-03 11:37:07 |
+---------------------------------------------------------+SELECT STR_TO_DATE('Tuesday, the 3rd day of March in that remarkable year 2015', '%W, the %D day of %M in that remarkable year %Y') AS florid;
+------------+
| florid |
+------------+
| 2015-03-03 |
+------------+Last modified: