My date column in my database is in this format: date('Y-M-j H:i:s');. A am trying to run a query to get all transactions done today and another one for all transactions done yesterday. Please help on best way to do this.
I tried the below but it wasn't working
$yesterday = date("Y-M-j 00:00:01", strtotime("-1 day")); $yesterday2 = date("Y-M-j 23:59:59", strtotime("-1 day")); $query_syesterday = "SELECT sum(amount), sum(amtnaira) FROM transactions WHERE transtype = 'buy' AND batch !='' AND date BETWEEN '$yesterday' AND '$yesterday2'"; $syesterday = mysql_query($query_syesterday, $egold1) or die(mysql_error()); $row_syesterday = mysql_fetch_assoc($syesterday); $totalRows_syesterday = mysql_num_rows($syesterday);