MySQL Whooped

This is for the benefit of those of you who found as little information as I did on Google about MySQL converting dates to Binary when using DATE_FORMAT, or just about any other formatting function inside your SQL. Now, I could have sworn I'd tried this before, but I must have been high on Pepsi. Anyway, here's the SQL that was giving me binary data:

DATE_FORMAT(tbl.field,'%Y-%m-01')

And here's what I did to make it work...:

CONVERT(DATE_FORMAT(tbl.field,'%Y-%m-01'),CHAR)

Your mileage may vary, but enjoy :)

Posted by Daniel Short on Feb 12, 2004 at 12:00 AM | Categories:

2 Comments

Mark

Mark wrote on 02/12/04 3:19 PM

yeah - but don't forget - Convert is a mySQL 4+ only function. I tend to just output the date as it comes, and do my formatting of it in CF itself. Just seems to make life so much easier. (I had this exact problem last week)
Daniel Short

Daniel Short wrote on 02/12/04 3:19 PM

Luckily for me this is for MySQL 4+ anyway ;). The issue isn't really about formatting though, because I'm using this data to group records, not simply for display purposes. I honestly have no idea why MySQL would *ever* return a simple date in binary format... just doesn't make sense.