In my previous blog, I've show how to convert a string in database to a datetime format. That syntax is only supported in mySQL 4.0 and above. In that version, it uses this syntax:
STR_TO_DATE(date,'%d/%m/%Y')
So, for mySQL 4.0 and below, just change the syntax to:
DATE_ADD( CONCAT(SUBSTRING_INDEX(`date`,'/',-1) , '-' , SUBSTRING_INDEX(substring_index(`date`,'/',2),'/',-1) , '-', SUBSTRING_INDEX(`date`,'/',1)), interval 0 day)
Example:
4.0 and above:
SELECT STR_TO_DATE(date,'%d/%m/%Y') AS myNewdate FROM myTable
below 4.0
SELECT DATE_ADD( CONCAT(SUBSTRING_INDEX(`date`,'/',-1) , '-' , SUBSTRING_INDEX(substring_index(`date`,'/',2),'/',-1) , '-', SUBSTRING_INDEX(`date`,'/',1)), interval 0 day) AS myNewdate FROM myTable
From: mr zoab
10 years ago