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

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

Order by string formatted date
Was this helpful?
0 Comments
Programming Feeds
Learn something new everyday on Devsheet