Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


how to compare dates

  • Please log in to reply
No replies to this topic

#1 12Strings


  • Members
  • 41 posts
  • Local time:01:35 AM

Posted 27 May 2015 - 12:15 AM

Hi,  I just want to update a database
table column (datepaid-type is DATE(YYYY-MM-DD) to the current date
IF the duedate  >= the current date, payrec = 'P', status = 'Y'and datepaid is ' '. I appreciate that my coding is dismal, sorry. Any help?

    $hostname = "localhost";
    $database = "homedb";
    $username = "root";
    $password = "cookie";
$dbconn = new PDO("mysql:host=$hostname;dbname=$database", $username, 

        $dbconn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $dbconn->exec('SET NAMES "utf8"');
 catch (PDOException $e)
        $error = "Unable to connect to the database server.";
        // Display error to user
$acctno="accto"; $payrec="payrec"; $status="status";
$duedate="duedate"; $datepaid="datepaid";
if($duedate == 'CURDATE')
        $query = $dbconn->prepare("
            UPDATE testbl SET $datepaid = CURDATE()
                payrec = 'P' AND status = 'Y' AND datepaid IS NULL
            ":acctno" => $_POST['acctno'],
            ":payrec" => $_POST['payrec'],
            ":status" => $_POST['status'],
            ":duedate" => $_POST["duedate"],
            ":datepaid" => $_POST["datepaid"]
catch(PDOException $e)
        $error = "Error retrieving user: ".$e->getMessage();
        // Display error to user


BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users