View Single Post
  #1 (permalink)  
Old 01-09-04, 09:01 PM
bitesize bitesize is offline
Newbie Coder
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
ERROR in SQL syntax near DATE_FORMAT()

To give you a little background, this is part of a calendar script that is searching for events in my database to populate the calendar.


Here is the query:
PHP Code:

$e_query mysql_query"

SELECT fnID, fnEventCategory, DATE_FORMAT(fdDateTime, '%l:%i') as time, fnHomeTeamID, fnAwayTeamID, fnHomeTeamScore, fnAwayTeamScore 
FROM tblGame, tblEvent 
WHERE
fnEventID = fnGameID
AND
DATE_FORMAT(fdDateTime, '%Y-%c-%e %H:%i:%s') > STR_TO_DATE(
$e_query_date, '%Y-%c-%e %H:%i:%s') 
AND 
DATE_FORMAT(fdDateTime, '%Y-%c-%e %H:%i:%s') < STR_TO_DATE(
$e_query_uDate, '%Y-%c-%e %H:%i:%s')
); 

fdDateTime is a DATETIME. I realize that using DATE_FORMAT on it might infact alter the format so it is not a DATETIME anymore, but I tried it without the DATE_FORMAT and it was the same error.

$e_query_date is a string that is a value like '2004-1-1 00:00:00'
$e_query_uDate is a string that is a value like '2004-1-1 23:59:59'


Here is the error message:
Code:
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 '('2004-1-1 00:00:00', '%Y-%c-%e %H:%i:%s')) AND fdDateTime < (S

Last edited by bitesize; 01-09-04 at 09:08 PM.
Reply With Quote