We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,608 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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

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!

4
Contributors
6
Replies
5 Days
Discussion Span
2 Months Ago
Last Updated
24
Views
kendaop
Light Poster
32 posts since Jan 2010
Reputation Points: 13
Solved Threads: 0
Skill Endorsements: 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?

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

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")
arrgh
Posting Pro in Training
405 posts since Dec 2008
Reputation Points: 32
Solved Threads: 50
Skill Endorsements: 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

pedrobl
Newbie Poster
4 posts since Aug 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

LastMitch
Industrious Poster
4,118 posts since Mar 2012
Reputation Points: 132
Solved Threads: 334
Skill Endorsements: 45

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.

arrgh
Posting Pro in Training
405 posts since Dec 2008
Reputation Points: 32
Solved Threads: 50
Skill Endorsements: 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?

arrgh
Posting Pro in Training
405 posts since Dec 2008
Reputation Points: 32
Solved Threads: 50
Skill Endorsements: 0

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.5296 seconds using 2.74MB