I have a table with a column called date
, as a varchar. The contents are specifically formatted like \'March 11, 2011\'.
How can I select the results have
I'm blindly assuming MySQL here, because it makes sense in the context of this question. Nobody using another database engine would dare create this problem in the first place.
STR_TO_DATE to the rescue! Given the format "March 01, 2000", the following conversion should work.
SELECT STR_TO_DATE(column_name, '%M %d, %Y')
FROM TableName
WHERE ...
ORDER BY STR_TO_DATE(column_name, '%M %d, %Y')
You may need to adjust the format string a bit.