MYSQL Help Needed with CURDATE()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • eMonk
    Confirmed User
    • Aug 2003
    • 2310

    #1

    MYSQL Help Needed with CURDATE()

    I'm trying to only fetch the rows where the expiry_date column is 3 days before today's date.

    Code:
    <?php
    
    include("../includes/connect.php");
    
    $query = "SELECT expiry_date FROM model WHERE expiry_date BETWEEN CURDATE() AND CURDATE() - INTERVAL 3 DAY";
    $result = $db->query($query);
    
    $num_results = $result->num_rows;
    
    echo "$num_results";
    
    ?>
    $num_results should echo "1" because there is 1 expiry_date column with "2011-11-17" but it's echoing "0". Any ideas?
  • woj
    <&(©¿©)&>
    • Jul 2002
    • 47880

    #2
    flip the 2 paramaters CURDATE() AND CURDATE() - INTERVAL 3 DAY

    what you have there is like asking for all numbers between 5 and 3, you need to ask for all numbers between 3 and 5
    Last edited by woj; 11-18-2011, 07:38 PM.
    Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
    Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
    Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

    Comment

    • marlboroack
      So Fucking Banned
      • Jul 2010
      • 9327

      #3
      Cool signature.

      Comment

      • eMonk
        Confirmed User
        • Aug 2003
        • 2310

        #4
        That worked thanks woj!!

        Comment

        Working...