kjtocool Posted August 1, 2008 Share Posted August 1, 2008 Hello, I am trying to format a date, but failing miserably. I've never worked with SQL Date formating, so it's likely I'm doing something silly, and couldn't find an answer on my own. Any help is greatly appreciated. The Query: SELECT a.userID, Date_Format( 'a.date', %M %D, %Y) AS theDate, a.review, b.typeName, c.name AS grade, d.movieName, d.year FROM myCinema_Reviews a, myCinema_Types b, myCinema_Grades c, myCinema_Movies d WHERE reviewID = '2' AND a.typeID = b.typeID AND a.grade = c.id AND a.movieID = d.movieID I basically want a.date converted from 'yyyy-mm-dd' (stored in the DB as type date) to something like: October 21, 2008 Thanks again for any help. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2008 Share Posted August 1, 2008 Single-quotes around your column name make it a string, not a column identifier. Quote Link to comment Share on other sites More sharing options...
kjtocool Posted August 1, 2008 Author Share Posted August 1, 2008 I had tried it that way originally, it blows up too: SELECT a.userID, Date_Format(a.date, % M % D, % Y ) AS theDate, a.review, b.typeName, c.name AS grade, d.movieName, d.year FROM myCinema_Reviews a, myCinema_Types b, myCinema_Grades c, myCinema_Movies d WHERE reviewID = '2' AND a.typeID = b.typeID AND a.grade = c.id AND a.movieID = d.movieID MySQL said: Documentation #1064 - 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 '%M %D, %Y) AS theDate, a.review, b.typeName, c.name AS grade, d.movieName, d.yea' at line 1 Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 1, 2008 Share Posted August 1, 2008 LOL. The format string needs single quotes around it. Quote Link to comment Share on other sites More sharing options...
kjtocool Posted August 1, 2008 Author Share Posted August 1, 2008 It's always something easy! Thanks, much appreciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.