zakiovi zakiovi - 3 months ago 18
MySQL Question

SELECT * FROM table Where CURDATE()

I have table product :


  • id : int;

  • name : varchar(255);

  • date_operation : datetime;



And i have some data in my table :

1, product1, 2016-08-19 11:10:00
2, product2, 2016-08-19 13:25:00
3, product3, 2016-08-20 07:05:00
4, product4, 2016-08-20 07:10:00
5, product5, 2016-08-20 07:25:00


I would like to view the products of today.

Example : today is: 2016-08-20

3, product3, 2016-08-20 07:05:00
4, product4, 2016-08-20 07:10:00
5, product5, 2016-08-20 07:25:00


I try with this code :

SELECT * FROM product WHERE date_operation = CURDATE()


But i have no result

Answer

could be you need date(date_operation) (you have datetime)

 SELECT * FROM product WHERE date(date_operation)  = CURDATE();