Current location: Hot Scripts Forums » Programming Languages » PHP » ERROR in SQL syntax near DATE_FORMAT()


ERROR in SQL syntax near DATE_FORMAT()

Reply
  #1 (permalink)  
Old 01-09-04, 10: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 10:08 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-09-04, 10:22 PM
bitesize bitesize is offline
Newbie Coder
 
Join Date: Sep 2003
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Nevermind, problem solved by avoiding the complexities of those functions

Final query used that worked:

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 fdDateTime > '$e_query_date' AND fdDateTime < '$e_query_uDate' ORDER BY fdDateTime ASC" );
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
syntax error plz help darkcarnival PHP 40 08-10-04 05:02 AM
Syntax error (missing operator) in query expression crobinson ASP 4 11-23-03 09:49 PM
SQL Code Syntax error...need help...missing operator geneane ASP 3 09-02-03 08:39 PM
Error: Syntax error converting datetime from character string. Han84 ASP 1 08-22-03 05:59 AM
change my field in this example sal21 ASP 3 07-14-03 03:49 AM


All times are GMT -5. The time now is 07:25 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.