PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have a varchar field which stores dates like "22/05/2004" UK format. When i asc or desc the order, the order i choose to display is not correct. How can i make the order display correct in the query.
This my query. I want the data to order by date using "Y-m-d" format from this field.
<?php
select * from studentsexp,tbl_school,tbl_location where studentsexp.SCHOOL_CODE = tbl_school.sc_code and tbl_location.lid = tbl_school.frn_lid and tbl_location.frn_cid = $frn_cid order by studentsexp.SCHOOL_CODE,studentsexp.DOB_DD_MM_ desc
?>
classic case of using the wrong type of field to store your data....you really shouldn't be storing dates as strings, instead, store the timestamp...trust me, it will make you life a whole lot easier
I always do store dates with data type date but i was given raw data in csv format woth DOB for students in UK date format.
I created another field called DOB and wrote a function to store the date in the correct format and then manipulated my data in the appropriate tables.
Thanks for your help people, i took your advise Calimero.