My WHERE Clause Using DatePart is Not Working the Way I Need it to
Posted on 2013-05-22
I am using the following WHERE clause to attemp to pull only data from LAST WEEK from a table
WHERE DatePart("ww", [15th_St_Panel_Plant_FPY.ProductionDate]) = (DatePart("ww", Date())-1) AND DatePart("yyyy", [15th_St_Panel_Plant_FPY.ProductionDate]) = (DatePart("yyyy", Date()));
However, when I compare the query return to manually calculated data from Last Week, the numbers do not match.
The ProductionDate is in the format mm/dd/yyyy. The first day of the week is intended to be Sunday.
Is there something in my Syntax, or am I just wrong in trying to do it this way?