Forums

How to sort a date in the format dd-mm-yyyy?

AntonioGraca 31 Mar, 2013
Hello

How to sort a date in the format dd-mm-yyyy?
I use the Datepicker to record the date in this format on a field varchar (255). So far so good.
The problem is that now I want to sort this field (by date) and it does not interpret as date field but as a number fied (make sense...).
I change the field in table to Date.
But, how to list data via the DB Multi Record Loader where the date is dd-mm-yyyy format?

How to solve?

Many thanks

António Graça
GreyHead 01 Apr, 2013
Hi António,

The answer is 'With difficulty' :-( The best solution is to save the date in a DATE or DATETIME column in the database. This takes a little more work in setting up but can make life easier later.

With the string values I think that the only way is to get the array of values from the DB Multi Record loader and use PHP to re-sort them into the order you need. It will probably require writing a custom sort function to make this work :-(

Bob

PS I found a similar question and answer here on StackExchange
AntonioGraca 01 Apr, 2013
Hello Bob
Thanks for the information to help solve the problem. I will try ...

thank you

António Graça
This topic is locked and no more replies can be posted.