Home > Back-end >  How to select data from an sql table ordered by datetime_received but only for the current date
How to select data from an sql table ordered by datetime_received but only for the current date

Time:08-02

I am trying to select specific data only for the current date.

My query is

sql="""
SELECT * from table where company_name ='XXX' 
AND company_id != 0 ORDER BY datetime_recieved 
"""  

I don't know what else to add, so it always selects only the current date.

CodePudding user response:

Assuming you want that datetime_recieved is current date:

SELECT * FROM table 
WHERE company_name ='XXX' AND company_id != 0 AND DATE(datetime_recieved) = DATE(NOW())
ORDER BY datetime_recieved 
  • Related