mysql

Order by Date where date in string format MySQL

STR_TO_DATE() function can be used to convert a string in Date format in Mysql. If you want to get results to order by date where the date is in string format, you can use this function.

SELECT Id, FirstName, Lastname
FROM Students 
ORDER BY STR_TO_DATE(CreatedDate, '%d-%m-%Y') ASC;

-- USE 'DESC' in place of 'ASC' if you want result in decending format
Was this helpful?