DATEDIFF Function

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I have a script that uses the following line

Code:
$month_sql = mysql_query("SELECT * FROM sales WHERE DATEDIFF(d, payment_date, NOW() ) < 365 ") or die(mysql_error());
I have not been able to get the code to work properly. I get the following error.

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

Any help is greatly appreciated
 

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
driveflexfuel said:
Code:
$month_sql = mysql_query("SELECT * FROM sales WHERE 
                          [COLOR=red][B]DATEDIFF(d, payment_date, NOW() )[/B][/COLOR] < 365 ") 
                                  or die(mysql_error());

I get the following error.

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

Well, the error message is telling you that you have the wrong number of parameters for that function.

You have 3: d , payment_date and NOW()

DATEDIFF , from the mySQL manual, only has two parameters, the two dates you are trying to get the difference of.
 
Last edited:

driveflexfuel

New Member
Messages
159
Reaction score
0
Points
0
I managed to figure it out. I converted this from another database language and the code I displayed above was sql but not mysql. I just had to remove "d," and it works fine.
 
Top