Return to Snippet

Revision: 53994
at December 6, 2011 00:55 by jpkunst

Initial Code
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;

Initial URL

Initial Description
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.

Initial Title
Convert textual dates of the form '[d]d-[m]m-yyyy' to actual dates

Initial Tags

Initial Language