/ Published in: MySQL
Converts textual dates like '1-3-1954' and '01-02-1963' to respectively '1954-3-1' and '1963-02-01'. MySQL is smart enough to understand the values without leading zeros when inserting into a DATE field.
Expand |
Embed | Plain Text
SELECT CONCAT(SUBSTRING_INDEX(`textual_date`, '-', -1), '-', TRIM('-' FROM MID(`textual_date`, LOCATE('-', `textual_date`) + 1, 2)), '-', SUBSTRING_INDEX(`textual_date`, '-',1)) AS year_month_day FROM table;
You need to login to post a comment.
