Q:

mysql: query to display data from previous day doesnt work when its a new month

When I run the below query on the first on a month it returns no data. It is supposed to display the previous day.
The query works ok normally except when it’s the first on the month, am I doing something wrong which will not allow it to see the previous days data as it’s a previous month?
select COUNT(*) from osticket.ost_ticket where  DATE(created) = DATE(NOW())-1

A:

You need to use DATE_SUB :
 select COUNT(*)
   from osticket.ost_ticket
  where  DATE(created) = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY));

