Important

Helios features are now enabled during weekly update windows and are no longer directly tied to SingleStore engine releases. Refer to the release notes to view the latest features available in your Helios cluster.

STR_TO_DATE

The STR_TO_DATE() 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_FORMAT for a description of format symbols.

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:

Was this article helpful?