1.11M Members

Incorrect parameter count in the call to native function 'DATE_FORMAT'

 
0
 

Hi, I'm pretty new to ColdFusion, and I was wondering if someone could give me a little help. I'm getting the following CF error:
Incorrect parameter count in the call to native function 'DATE_FORMAT'
Here's the code that's producing it.

<cfquery name="qryGetDateName" datasource="DATABASE" result="RESULT">
       SELECT DATE_FORMAT(Events.event_date,"%W") AS "Date"
       FROM Events
       WHERE event_id = 100
       LIMIT 1;
</cfquery>   

When I run this query separately on the database, it executes just fine, but it's giving me this error when I try to execute it from a ColdFusion file. Can anyone help me?

Thanks!

LastMitch
Deleted Member
 
0
 

Incorrect parameter count in the call to native function 'DATE_FORMAT'

This issue you are having has nothing to do with ColdFusion at all.

So that's not really an excuse.

The issue is your Query which is incorrect.

What is Events.event_date?

 
0
 

Here's the code that's producing it.

What you posted works perfectly w/CF10 and mySQL. Are you 100% positive that's the SQL you're using? Because a common cause of that error is forgetting the comma before the date mask ie

    DATE_FORMAT(Events.event_date "%W") 

instead of

    DATE_FORMAT(Events.event_date  , "%W")
 
0
 

Hi,

As LastMitch said, it's not a coldfusion error, but a MySQL. MySQL requires the strings to be enclosed with single quotes... that may be the cause. Try the following:

DATE_FORMAT(Events.event_date,'%W')

HTH

LastMitch
Deleted Member
 
0
 

MySQL requires the strings to be enclosed with single quotes

What is Events.event_date?

You need to explain what is it.

So we can fixed the query.

You are correct regarding about the strings.

 
0
 

MySQL requires the strings to be enclosed with single quotes... that may be the cause.

Not strictly true. FWIW, MySQL accepts either single or double quotes. But changing them is worth a try, since single quotes are more standard for string literals in jdbc anyway.

Agreed, it's a SQL error. But like I said, that exact code works perfectly from CF10. So something is different on their end.

 
0
 

BTW, did either of you actually test the query...? If yes, what were your results and what version of CF/mySQL are you running?

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article