varchar date sort by date

I have a db that has a date stored as a varchar.
I know this is bad, but it is not going to change.

How do I sort the results by date?

select * from table1 order by date?

Thanks
jackjohnson44Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

todd_farmerCommented:
SELECT * FROM table1 ORDER BY STR_TO_DATE(date, '%m/%d/%Y')
0
jackjohnson44Author Commented:
that didn't work

my date format is 3/29/2006
0
todd_farmerCommented:
The date conversion will work for that format:


mysql> select STR_TO_DATE('3/29/2006', '%m/%d/%Y');
+--------------------------------------+
| STR_TO_DATE('3/29/2006', '%m/%d/%Y') |
+--------------------------------------+
| 2006-03-29                           |
+--------------------------------------+
1 row in set (0.01 sec)

Can you give me a better understanding of what you mean when you say it doesn't work?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

jackjohnson44Author Commented:
I am getting this error

select * from subscriptions where type='Paid' order by STR_TO_DATE(`date`, '%m/%d/%Y')

You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(`date`, '%m/%d/%Y')' at line 1
0
todd_farmerCommented:
What version of MySQL are you running?  It seems like it may be an older version.
0
jackjohnson44Author Commented:
Thanks for you help.

I am not sure, how do I tell?

If I am running an older version, is there any way around this?
0
todd_farmerCommented:
SELECT VERSION();

should give you the version.

Let's see what you're working with, then perhaps we can look for workarounds.
0
jackjohnson44Author Commented:
I just conveted the type to date.

How do I insert the current date into an insert query?
0
todd_farmerCommented:
INSERT INTO table1 (date) VALUES (NOW());
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.