View Single Post
Old 08-21-2005, 01:16 AM   #1 (permalink)
harryhood
The Visitor
 
Join Date: Mar 2005
Posts: 3
Thanks: 0
harryhood is on a distinguished road
Default converting to mysql date format

I have a query I'm working on that pulls data from 2 columns, named 'Month' and 'Year'. I want to then combine these two columns to a date and order the results by that that date. I've been trying for a while with little success, so I'd be greatful for any help.

Here are the 2 methods I've been trying what I have tried:

1)
PHP Code:
"SELECT Month, Year FROM order ORDER BY str_to_date(CONCAT_WS('-',Year,Month,'01 00:00:00'),'%Y/%m/%d') asc" 
2)
PHP Code:
"SELECT Month, Year FROM order ORDER BY CAST(CONCAT_WS('-',Year,Month,'01') AS DATE) asc" 
Any suggestions or other ways to accomplish this?

thanks!
harryhood is offline  
Reply With Quote