I am currently creating a website on which I can add videos. When I add a video, I need to give a release date, formatted like: “21-09-2012”.
Now, when I use the simple ORDER BY command, it only sorts on the first two digits.
Does anyone know how can I fix this?
It sounds like you are storing your date field as a string instead. If that it the case then you will need to convert the value to a date before trying to order it:
MySQL documentation on
STR_TO_DATEHowever, you should be storing your dates in a date datatype and not as a string value. Then you will not have to perform these types of conversions.
You can also do the conversion in the ORDER BY statement itself: