//day variables
$yesterday = date('d', mktime(0, 0, 0, date("m"), date("d")-1, date("Y")));
//query
$yorders = "SELECT * FROM orders WHERE DAY(dateadded)='$yesterday' AND status!='Quote'";
$yordersq = mysql_query($yorders, $db_conn) or die("Query $yordersq Failed".mysql_error());
I keep getting a syntax error in the query though i can't seem to see the problem. It's setup in the same format as month and year queries which are fine.
For something like this, I usually find the stamp for 0:00:00 and for 23:59:59 and find entries between those two values.
Also, you should generate a timestamp once, and use that when generating the $yesterday variable. Imagine if the the script started at 11:59:59.9 December 31st then changed to January 1st halfway through assigning the $yesterday variable - you'd have quite the messed up stamp. This could happen over any day-change period.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
i have the required version of MySQL for DAY, it even shows up the right number in the query error. I just need to get it to draw using the DAY, once that works i can make sure it's using the right month and year.
It sure won't. If you cross over months without decrimenting the month, you'll have an invalid stamp. Plus, you have to worry about going January->December. An easier way to do it would be to generate a timestamp and subtract 86400 (#of seconds in a day) from it: