P粉4364105862023-09-03 09:07:18
If you knew that all two-digit years greater than a certain value, say '50'
, should be considered years in the 1900s, and the rest should be considered years in the 2000s, you Different date formats can be applied using CASE
expressions:
SELECT DATE(STR_TO_DATE( date, CASE WHEN RIGHT(date, 2) < ? THEN '%d-%M-%Y' ELSE '%d-%M-%y' END )) date FROM tablename;
Change ?
to a two-digit year that fits your data (such as '50'
).
See Demo.