May 2005
Intermediate to advanced
352 pages
14h 39m
English
STR_TO_DATE( )
STR_TO_DATE(datetime, 'format_code')
This function returns the date and time of a given string for a given
format. The function takes a string containing a date or time, or
both. So that the function may convert the string given, the
formatting code for the string needs to be provided. The formatting
codes are the same codes used by the DATE_FORMAT() function. This function is available as of Version 4.1.1
of MySQL.
SELECT STR_TO_DATE('January 15, 2005 1:30 PM',
'%M %d, %Y %h:%i %p')
AS Anniversary;
+---------------------+
| Anniversary |
+---------------------+
| 2005-01-15 13:30:00 |
+---------------------+Read now
Unlock full access