-1

I am using this code. In column there are values of 2020-07-06 11:59:34 and 2020-07-06 11:59:45. I don't want to compare time but only date. I want to check if column value is today date. But the output of this code is 0.

require_once "connect.php";

$followers = $conn->query("SELECT  *  FROM followers WHERE DATE('created_date') = CURDATE() and profile_id=1");

echo $followers->num_rows;
  • `'created_date'` is a string. Perhaps you were thinking of `created_date`. Also, note that functions cannot use indexes, so something like `created_date` BETWEEN CURDATE() AND CURDATE() + INTERVAL 1 DAY` is preferable – Strawberry Jul 06 '20 at 08:30
  • I don't understand. created_date is column name and its type is timestamp – Junaid Rehman Jul 06 '20 at 08:32
  • 1
    Anything wrapped in inverted commas is a string, not a column. – Strawberry Jul 06 '20 at 08:36

1 Answers1

0

don't use single quotes for columns name (eventually use backtics when needed)

SELECT  *  FROM followers WHERE DATE(created_date) = CURDATE() and profile_id=1
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107