Get data of yesterday, tomorrow and last week by Mysql query from Database

To get Yesterday’s data from the database table

  1. mysql_query("select * from table where date = ".date("Y-m-d", strtotime("-1 day")));
  2. mysql_query(“select * from table where date = NOW()-INTERVAL 1 DAY”);

To get Tomorrow’s data

  1. mysql_query(“select * from table where date = “.date(“Y-m-d”, strtotime(“+1 day”)));
  2. mysql_query(“select * from table where date = NOW()+INTERVAL 1 DAY”);

To get Last Week data

mysql_query(“select * from tbl where date between NOW() – INTERVAL DAYOFWEEK(NOW())+6 DAY AND NOW() – INTERVAL DAYOFWEEK(NOW())-1 DAY”);

Leave a Reply