studgate Posted March 8, 2007 Share Posted March 8, 2007 I have the date in my database like yyyy/mm/dd (2000/01/01) and I want to select it from the database as mm/dd/yyyy(01/01/2000) the date column is "date_ur" What I have is: $sql_date = mysql_query("SELECT date_format(date_ur, '%M %D %Y') as date, COUNT(*) as num FROM table GROUP BY date ORDER BY date") or die("Error in $strsql\n" . mysql_error()); I am not getting anything right now. What am I doing wrong?? Any help is welcome! Thanks in advance Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/ Share on other sites More sharing options...
.Darkman Posted March 8, 2007 Share Posted March 8, 2007 Try this :- $sql_date = mysql_query("SELECT DATE_FORMAT(date_ur, '%M %D %Y') as date, COUNT(*) as num FROM table GROUP BY date ORDER BY date") or die("Error in $strsql\n" . mysql_error()); Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202189 Share on other sites More sharing options...
artacus Posted March 8, 2007 Share Posted March 8, 2007 Hint: Date is a reserved word... one that everyone likes to use as a column name Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202190 Share on other sites More sharing options...
.Darkman Posted March 8, 2007 Share Posted March 8, 2007 I think it can be used as Column. I do it and it works. But i think it cannot be "SELECT as date" Maybe change it to something. Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202199 Share on other sites More sharing options...
studgate Posted March 8, 2007 Author Share Posted March 8, 2007 I still didn't work, thanks though Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202203 Share on other sites More sharing options...
jcbarr Posted March 8, 2007 Share Posted March 8, 2007 I have run in to this before, you just have to make sure you put ` ` around it. Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202204 Share on other sites More sharing options...
studgate Posted March 8, 2007 Author Share Posted March 8, 2007 AROUND WHAT?? Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202205 Share on other sites More sharing options...
jcbarr Posted March 8, 2007 Share Posted March 8, 2007 I was referring to using the word date, if you put `date` it will not treat it as a reserved word and you won't have those sorts of problems. Not sure if that will help you or not though... Link to comment https://forums.phpfreaks.com/topic/41703-select-date-help/#findComment-202207 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.