SELECT STR_TO_DATE(LEFT(booking_date , 10), '%c/%e/%Y') from mycase
The booking_date is my field and contain data like 01-10-2015 Evening ( 3PM - 6PM ).
And i want to first get the date and after that i want to convert that into date type in MySQL.
答案 0 :(得分:0)
You need to change /
to -
in the str_to_time
function since your input dates are in the format 01-10-2015
mysql> SELECT STR_TO_DATE(LEFT('01-10-2015 Evening ( 3PM - 6PM )' , 10), '%c-%e-%Y') as d ;
+------------+
| d |
+------------+
| 2015-01-10 |
+------------+
SELECT STR_TO_DATE(LEFT(booking_date , 10), '%c-%e-%Y') from mycase