I have a table with future values where I only want the last full week.
Meaning af want to find the last Sunday and have a WHERE clause where date is between 'last Sunday - 7' and 'last Sunday'.
Meaning I have transactions until '31-10-2018' and want the period between '2018-10-28' and '2018-10-22' (both days included). But every week new data will be added continuously so very soon I have data until '2018-11-30' and so on.
I have tried a query like:
SELECT *
FROM PlannedCounts
WHERE [Date] BETWEEN DATEADD(d,-6,MAX([Date])) and MAX([Date])
Note: I'm aware that this will only give me last day ('2018-10-31' and not last Sunday).
How can I include calculated dates in my where claus and also conditioning the target date to be last Sunday?
My table have the following columns:
Date
Location
Type
Material
Value
Manager