Search code snippets, questions, articles...

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
Best JSON Validator, JSON Tree Viewer, JSON Beautifier at same place.

Search Index Data (The code snippet can also be found with below search text)

Order by string formatted date
Was this helpful?