+ Reply to Thread
Results 1 to 3 of 3

Thread: DATEDIFF Function

  1. #1
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    DATEDIFF Function

    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

  2. #2
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: DATEDIFF Function

    Quote Originally Posted by driveflexfuel


    Code:
     
    $month_sql = mysql_query("SELECT * FROM sales WHERE 
                              DATEDIFF(d, payment_date, NOW() ) < 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 by descalzo; 10-15-2009 at 06:13 PM.
    Nothing is always absolutely so.

  3. #3
    driveflexfuel is offline x10 Sophmore driveflexfuel is an unknown quantity at this point
    Join Date
    Jul 2008
    Posts
    159

    Re: DATEDIFF Function

    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.

+ Reply to Thread

Similar Threads

  1. Help with php function
    By zyreena in forum Programming Help
    Replies: 8
    Last Post: 05-13-2009, 10:17 AM
  2. Call to function from action attribute of form tag
    By parkourmumbai in forum Programming Help
    Replies: 10
    Last Post: 10-14-2008, 06:47 AM
  3. Replies: 2
    Last Post: 08-17-2008, 08:30 PM
  4. Drop-Down Menu problems
    By gmshed in forum Programming Help
    Replies: 3
    Last Post: 04-11-2008, 12:33 AM
  5. Easy XHTML form validation using PHP
    By Xemnas in forum Tutorials
    Replies: 0
    Last Post: 01-08-2008, 04:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers