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!

Recommended Answers

All 6 Replies

Member Avatar for LastMitch

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?

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")
Member Avatar for pedrobl

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

Member Avatar for LastMitch

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.

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.