Question

In my DB when a new user register I use now() for the column date_added (I need the exact time of registration). Also I store the user ip in column ip

Now I need to check in SQL if there is already registration from this ip from today

BUT

    $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer 
    WHERE ip = '" . $this->db->escape($ip) . "' 
    AND date_added = CURDATE()");

    return $query->row;

Does not work because I use now() for date_added and now() is not = to curdate()

Any ideas how to do the trick?

Was it helpful?

Solution

Use DATE()

... AND date(date_added) = CURDATE()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top