How to sort a varchar field with "/"

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!

Moderator: General Moderators

Post Reply
stevenh
Forum Newbie
Posts: 1
Joined: Wed Dec 28, 2011 6:46 pm

How to sort a varchar field with "/"

Post by stevenh »

I have a varchar field called date that looks like this "2/06/2011 TUE" or like this "10/05/2011 WED".
When I do an Order BY date Desc in php it does Not sort properly.
Thanks for your assistance

Steve
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: How to sort a varchar field with "/"

Post by s.dot »

You could try ORDER BY UNIX_TIMESTAMP(date) DESC
Or some other mysql date/time functions
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply