Data-base order on website
I have a mysql database which is displayed on my site with the fields in the DB being Date which is the date of the event, Location which is where the event will be held and the ID which is for admin purposes only... I also added an altdate which is specificly for ordering the display of the DB on the site which in the mysql DB is altdate. I insert this using the date format d-m-y, but im not getting the correct order of how it displays on the site when i re-order it on the site
SELECT * FROM $tbl_name ORDER BY `altdate` ASC
If i add some to the events from the month of may and then add some from the month of june then the ones for the month in june will go above some of the events that happen in may because of the date of that month if you see the image here
you can see 1st of june has gone above 2 events that happen in may when i need the one in june to be at the bottom because it is the furthest away.
Any help would be appriciated! Thanks
If you are inserting your dates in that format then you are using CHAR or VARCHAR for your column type.
Originally Posted by Timms
Instead use DATE type for the column and insert as yyyymmdd and then use DATE_FORMAT when you pull the dates if you need them to appear in a different way.